handling files when stages and dirty at once
This commit is contained in:
@@ -25,6 +25,7 @@ const api = {
|
||||
readDir: (path: string) => ipcRenderer.invoke('fs:readDir', path),
|
||||
files: () => ipcRenderer.invoke('fs:files'),
|
||||
read: (path: string) => ipcRenderer.invoke('fs:read', path),
|
||||
imageDataUrl: (path: string): Promise<string> => ipcRenderer.invoke('fs:imageDataUrl', path),
|
||||
write: (path: string, content: string): Promise<void> => ipcRenderer.invoke('fs:write', path, content),
|
||||
delete: (path: string): Promise<void> => ipcRenderer.invoke('fs:delete', path),
|
||||
create: (path: string): Promise<void> => ipcRenderer.invoke('fs:create', path),
|
||||
@@ -83,6 +84,18 @@ const api = {
|
||||
ipcRenderer.invoke('dialog:unsavedClose', path),
|
||||
},
|
||||
|
||||
/** Renderer errors → the main process log file (see renderer/src/log.ts).
|
||||
* `write` is fire-and-forget on purpose: logging must never await, and must
|
||||
* never be able to reject into the very handler that's reporting a failure. */
|
||||
log: {
|
||||
write: (level: 'debug' | 'info' | 'warn' | 'error', scope: string, msg: string, ctx?: unknown): void => {
|
||||
ipcRenderer.send('log:write', level, scope, msg, ctx)
|
||||
},
|
||||
path: (): Promise<string | null> => ipcRenderer.invoke('log:path'),
|
||||
open: (): Promise<void> => ipcRenderer.invoke('log:open'),
|
||||
reveal: (): Promise<void> => ipcRenderer.invoke('log:reveal'),
|
||||
},
|
||||
|
||||
/** Subscribe to "the project changed on disk" pings. Returns an unsubscribe. */
|
||||
onProjectChanged: (cb: () => void): (() => void) => {
|
||||
const handler = (): void => cb()
|
||||
@@ -96,6 +109,13 @@ const api = {
|
||||
ipcRenderer.on('config:changed', handler)
|
||||
return () => ipcRenderer.removeListener('config:changed', handler)
|
||||
},
|
||||
|
||||
/** Subscribe to explicit ⌘R refresh requests (git + tree + viewer). Returns an unsubscribe. */
|
||||
onRefresh: (cb: () => void): (() => void) => {
|
||||
const handler = (): void => cb()
|
||||
ipcRenderer.on('view:refresh', handler)
|
||||
return () => ipcRenderer.removeListener('view:refresh', handler)
|
||||
},
|
||||
}
|
||||
|
||||
if (process.contextIsolated) {
|
||||
|
||||
Reference in New Issue
Block a user