From 4fb636e91c43b137b7866ca877b5ed40bcf41d6d Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 14 Dec 2024 00:50:26 +0900
Subject: [PATCH] refs #5097 Add context menu to save images
---
main/background.ts | 20 +++++++++++++++++++
.../components/timelines/FollowRequests.tsx | 20 +++++++++----------
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/main/background.ts b/main/background.ts
index e2a73e7b..9b4893d6 100644
--- a/main/background.ts
+++ b/main/background.ts
@@ -39,6 +39,26 @@ let main: BrowserWindow = null
await mainWindow.loadURL(`http://localhost:${port}/`)
mainWindow.webContents.openDevTools()
}
+
+ mainWindow.webContents.on('context-menu', (_event, properties) => {
+ const contextMenu = Menu.buildFromTemplate([
+ {
+ label: 'Select All',
+ click: () => {
+ mainWindow.webContents.selectAll()
+ }
+ },
+ {
+ label: 'Save Image As',
+ visible: properties.mediaType === 'image',
+ click: () => {
+ console.log(properties.srcURL)
+ mainWindow.webContents.downloadURL(properties.srcURL)
+ }
+ }
+ ])
+ contextMenu.popup({ window: mainWindow })
+ })
})()
app.on('window-all-closed', () => {
diff --git a/renderer/components/timelines/FollowRequests.tsx b/renderer/components/timelines/FollowRequests.tsx
index eceb8687..d2bc5344 100644
--- a/renderer/components/timelines/FollowRequests.tsx
+++ b/renderer/components/timelines/FollowRequests.tsx
@@ -54,17 +54,15 @@ export default function FollowRequests(props: Props) {
{requests.map(r => (
- <>
- {
- const data = await refreshRequests()
- updateUnreads(data.length)
- }}
- />
- >
+ {
+ const data = await refreshRequests()
+ updateUnreads(data.length)
+ }}
+ />
))}