Skip to content

Commit 7fcd9e5

Browse files
committed
allow copying error message for imports
1 parent ad30f6b commit 7fcd9e5

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

src/bridges/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const utilsBridge = {
1717
ipcRenderer.invoke("open-external", url, background)
1818
},
1919

20-
showErrorBox: (title: string, content: string) => {
21-
ipcRenderer.invoke("show-error-box", title, content)
20+
showErrorBox: (title: string, content: string, copy?: string) => {
21+
ipcRenderer.invoke("show-error-box", title, content, copy)
2222
},
2323

2424
showMessageBox: async (

src/main/utils.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,23 @@ export function setUtilsListeners(manager: WindowManager) {
4545
openExternal(url, background)
4646
})
4747

48-
ipcMain.handle("show-error-box", (_, title, content) => {
49-
dialog.showErrorBox(title, content)
48+
ipcMain.handle("show-error-box", async (_, title, content, copy?: string) => {
49+
if (manager.hasWindow() && copy != null) {
50+
const response = await dialog.showMessageBox(manager.mainWindow, {
51+
type: 'error',
52+
title: title,
53+
message: title,
54+
detail: content,
55+
buttons: ["OK", copy],
56+
cancelId: 0,
57+
defaultId: 0,
58+
})
59+
if (response.response === 1) {
60+
clipboard.writeText(`${title}: ${content}`);
61+
}
62+
} else {
63+
dialog.showErrorBox(title, content)
64+
}
5065
})
5166

5267
ipcMain.handle(
@@ -56,7 +71,8 @@ export function setUtilsListeners(manager: WindowManager) {
5671
let response = await dialog.showMessageBox(manager.mainWindow, {
5772
type: type,
5873
title: title,
59-
message: message,
74+
message: title,
75+
detail: message,
6076
buttons:
6177
process.platform === "win32"
6278
? ["Yes", "No"]

src/scripts/models/group.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ export function importOPML(): AppThunk {
300300
.map(e => {
301301
return e[0] + "\n" + String(e[1])
302302
})
303-
.join("\n")
303+
.join("\n"),
304+
intl.get("context.copy")
304305
)
305306
}
306307
})

src/scripts/models/source.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ export function addSource(
323323
if (!batch) {
324324
window.utils.showErrorBox(
325325
intl.get("sources.errorAdd"),
326-
String(e)
326+
String(e),
327+
intl.get("context.copy")
327328
)
328329
}
329330
throw e

0 commit comments

Comments
 (0)