fix(desktop): add error handling to store-get IPC handler (#25850)
This commit is contained in:
@@ -70,10 +70,14 @@ export function registerIpcHandlers(deps: Deps) {
|
|||||||
ipcMain.handle("install-update", () => deps.installUpdate())
|
ipcMain.handle("install-update", () => deps.installUpdate())
|
||||||
ipcMain.handle("set-background-color", (_event: IpcMainInvokeEvent, color: string) => deps.setBackgroundColor(color))
|
ipcMain.handle("set-background-color", (_event: IpcMainInvokeEvent, color: string) => deps.setBackgroundColor(color))
|
||||||
ipcMain.handle("store-get", (_event: IpcMainInvokeEvent, name: string, key: string) => {
|
ipcMain.handle("store-get", (_event: IpcMainInvokeEvent, name: string, key: string) => {
|
||||||
const store = getStore(name)
|
try {
|
||||||
const value = store.get(key)
|
const store = getStore(name)
|
||||||
if (value === undefined || value === null) return null
|
const value = store.get(key)
|
||||||
return typeof value === "string" ? value : JSON.stringify(value)
|
if (value === undefined || value === null) return null
|
||||||
|
return typeof value === "string" ? value : JSON.stringify(value)
|
||||||
|
} catch {
|
||||||
|
return null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
ipcMain.handle("store-set", (_event: IpcMainInvokeEvent, name: string, key: string, value: string) => {
|
ipcMain.handle("store-set", (_event: IpcMainInvokeEvent, name: string, key: string, value: string) => {
|
||||||
getStore(name).set(key, value)
|
getStore(name).set(key, value)
|
||||||
|
|||||||
Reference in New Issue
Block a user