feat: support image lightbox viewer and file download (#151)

* feat: add lightbox overlay with nice mechanics

* ui tweak for top bar in stream view

* support locally downloading attachments
This commit was merged in pull request #151.
This commit is contained in:
Arjun Patel
2026-04-12 14:14:23 -07:00
committed by GitHub
parent dbe61e447a
commit 5b6924f7ca
10 changed files with 602 additions and 146 deletions
+22
View File
@@ -454,6 +454,28 @@ ipcMain.handle('link:open-external', async (_event, url: string) => {
await shell.openExternal(url);
});
// --- Attachment download ---
// Triggers a native download with save-as dialog. Cross-origin safe — unlike
// the web `<a download>` hack, which is ignored for cross-origin URLs.
ipcMain.on(
'attachment:download',
(event, payload: { url: string; filename?: string }) => {
const win = BrowserWindow.fromWebContents(event.sender);
if (!win) return;
const { url, filename } = payload ?? {};
if (typeof url !== 'string') return;
if (!url.startsWith('http://') && !url.startsWith('https://')) return;
const dlSession = win.webContents.session;
const onWillDownload = (_e: Electron.Event, item: Electron.DownloadItem) => {
if (filename) item.setSaveDialogOptions({ defaultPath: filename });
dlSession.removeListener('will-download', onWillDownload);
};
dlSession.on('will-download', onWillDownload);
win.webContents.downloadURL(url);
},
);
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.