Fix L49/L53/L59: error string newlines, dialog null-safety, shared theme constant
L49: Remove newline from missing-binary error message in download.ts; inline
error spans render it as literal newline, now one sentence with period.
L53: backup.ts exportBackup/importBackup/showMessageBox no longer use win!
non-null assertions -- each uses a guarded ternary (same pattern index.ts
already used for chooseFolder).
L59: Extract PAGE_BACKGROUND to src/shared/theme.ts; main/index.ts and
renderer/src/theme.ts both import from it -- no more "keep in sync" comment.
typecheck + 242 tests + eslint + prettier green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+13
-8
@@ -12,10 +12,11 @@ interface BackupFile {
|
||||
}
|
||||
|
||||
export async function exportBackup(win: BrowserWindow | undefined): Promise<BackupExportResult> {
|
||||
const res = await dialog.showSaveDialog(win!, {
|
||||
const opts = {
|
||||
defaultPath: 'aerofetch-backup.json',
|
||||
filters: [{ name: 'JSON', extensions: ['json'] }]
|
||||
})
|
||||
}
|
||||
const res = await (win ? dialog.showSaveDialog(win, opts) : dialog.showSaveDialog(opts))
|
||||
if (res.canceled || !res.filePath) return { ok: false }
|
||||
// Strip credentials (proxy creds, API tokens) so a backup file shared or synced
|
||||
// to the cloud doesn't leak secrets in plaintext (M22). The user re-enters them
|
||||
@@ -32,10 +33,11 @@ export async function exportBackup(win: BrowserWindow | undefined): Promise<Back
|
||||
}
|
||||
|
||||
export async function importBackup(win: BrowserWindow | undefined): Promise<BackupImportResult> {
|
||||
const res = await dialog.showOpenDialog(win!, {
|
||||
properties: ['openFile'],
|
||||
const openOpts = {
|
||||
properties: ['openFile' as const],
|
||||
filters: [{ name: 'JSON', extensions: ['json'] }]
|
||||
})
|
||||
}
|
||||
const res = await (win ? dialog.showOpenDialog(win, openOpts) : dialog.showOpenDialog(openOpts))
|
||||
if (res.canceled || !res.filePaths[0]) return { ok: false }
|
||||
|
||||
let parsed: unknown
|
||||
@@ -86,8 +88,8 @@ export async function importBackup(win: BrowserWindow | undefined): Promise<Back
|
||||
})
|
||||
.join('\n')
|
||||
const more = commandTemplates.length > 10 ? `\n…and ${commandTemplates.length - 10} more.` : ''
|
||||
const choice = await dialog.showMessageBox(win!, {
|
||||
type: 'warning',
|
||||
const msgOpts = {
|
||||
type: 'warning' as const,
|
||||
buttons: ['Enable custom commands', 'Import without enabling', 'Cancel'],
|
||||
defaultId: 1,
|
||||
cancelId: 2,
|
||||
@@ -99,7 +101,10 @@ export async function importBackup(win: BrowserWindow | undefined): Promise<Back
|
||||
'Custom commands run extra yt-dlp flags on every download. Only enable them if you trust this backup file.\n\n' +
|
||||
preview +
|
||||
more
|
||||
})
|
||||
}
|
||||
const choice = await (win
|
||||
? dialog.showMessageBox(win, msgOpts)
|
||||
: dialog.showMessageBox(msgOpts))
|
||||
if (choice.response === 2) return { ok: false } // Cancel — change nothing
|
||||
applyCustomCommands = choice.response === 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user