All files / app/main register-store-handlers.ts

0% Statements 0/17
100% Branches 0/0
0% Functions 0/7
0% Lines 0/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                                                   
import { ipcMain } from 'electron';
import Store from 'electron-store';
import path from 'path';
 
export function registerIpcStoreHandlers(userDataPath: string) {
  const store = new Store({
    clearInvalidConfig: true,
    cwd: userDataPath,
  });
 
  ipcMain.on('get-user-data-path', e => (e.returnValue = path.join(userDataPath, 'config.json')));
 
  ipcMain.handle('store-set', (_e, { key, value }: any) => store.set(key, value));
 
  ipcMain.handle('store-get', (_e, { key }: any) => store.get(key));
 
  ipcMain.handle('store-delete', (_e, { key }: any) => store.delete(key));
 
  // ipcMain.handle('store-getEntireStore', () => store.store);
  ipcMain.handle('store-clear', () => store.clear());
 
  ipcMain.on('store-getEntireStore', event => {
    event.returnValue = store.store;
  });
}