Files
actual/packages/desktop-electron/preload.ts
Michael Clark a7b8d1251c :electron: Move file settings to the file management area (#3584)
* move settings to the file management area

* more settings

* giving users option to automatically move files when changing dir

* trueee

* updates

* does this fix the type issue

* weird

* translating

* release notes

* release notes

* a bit extra safety

* updating wording

* parameterising backup params

* text update

* parameterise vals

* add a notification to ensure the user knows the dir has changed

* pencil icon to save real estate

* ordering

* Rename 3500.md to 3584.md

* Update packages/desktop-client/src/components/manager/BudgetList.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2024-10-07 19:34:25 +01:00

88 lines
2.0 KiB
TypeScript

import { ipcRenderer, contextBridge, IpcRenderer } from 'electron';
import {
GetBootstrapDataPayload,
OpenFileDialogPayload,
SaveFileDialogPayload,
} from './index';
const { version: VERSION, isDev: IS_DEV }: GetBootstrapDataPayload =
ipcRenderer.sendSync('get-bootstrap-data');
contextBridge.exposeInMainWorld('Actual', {
IS_DEV,
ACTUAL_VERSION: VERSION,
logToTerminal: console.log,
ipcConnect: (
func: (payload: {
on: IpcRenderer['on'];
emit: (name: string, data: unknown) => void;
}) => void,
) => {
func({
on(name, handler) {
return ipcRenderer.on(name, (_event, value) => handler(value));
},
emit(name, data) {
return ipcRenderer.send('message', { name, args: data });
},
});
},
relaunch: () => {
ipcRenderer.invoke('relaunch');
},
restartElectronServer: () => {
ipcRenderer.invoke('restart-server');
},
openFileDialog: (opts: OpenFileDialogPayload) => {
return ipcRenderer.invoke('open-file-dialog', opts);
},
saveFile: async (
contents: SaveFileDialogPayload['fileContents'],
filename: SaveFileDialogPayload['defaultPath'],
dialogTitle: SaveFileDialogPayload['title'],
) => {
await ipcRenderer.invoke('save-file-dialog', {
title: dialogTitle,
defaultPath: filename,
fileContents: contents,
});
},
openURLInBrowser: (url: string) => {
ipcRenderer.invoke('open-external-url', url);
},
onEventFromMain: (type: string, handler: (...args: unknown[]) => void) => {
ipcRenderer.on(type, handler);
},
updateAppMenu: (budgetId?: string) => {
ipcRenderer.send('update-menu', budgetId);
},
getServerSocket: () => {
return null;
},
setTheme: (theme: string) => {
ipcRenderer.send('set-theme', theme);
},
moveBudgetDirectory: (
currentBudgetDirectory: string,
newDirectory: string,
) => {
return ipcRenderer.invoke(
'move-budget-directory',
currentBudgetDirectory,
newDirectory,
);
},
});