Skip to content

Commit

Permalink
yo
Browse files Browse the repository at this point in the history
  • Loading branch information
MikesGlitch committed Feb 21, 2025
1 parent cb4a4fa commit c3f1600
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function CustomReportInner({ report: initialReport }: CustomReportInnerProps) {
const location = useLocation();

const prevUrl = sessionStorage.getItem('url') || '';

sessionStorage.setItem('prevUrl', prevUrl);
sessionStorage.setItem('url', location.pathname);

Expand Down
39 changes: 8 additions & 31 deletions packages/desktop-electron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,33 +86,6 @@ const logMessage = (loglevel: 'info' | 'error', message: string) => {
}
};

let queuedClientWinLogs: string[] = []; // logs that are queued up until the client window is ready

const logMessage = (loglevel: 'info' | 'error', message: string) => {
// Electron main process logs
switch (loglevel) {
case 'info':
console.info(message);
break;
case 'error':
console.error(message);
break;
}

if (!clientWin) {
// queue up the logs until the client window is ready
queuedClientWinLogs.push(
// eslint-disable-next-line rulesdir/typography
`console.${loglevel}('Actual Sync Server Log:', ${JSON.stringify(message)})`,
);
} else {
// Send the queued up logs to the devtools console
clientWin.webContents.executeJavaScript(
`console.${loglevel}('Actual Sync Server Log:', ${JSON.stringify(message)})`,
);
}
};

const createOAuthServer = async () => {
const port = 3010;
logMessage('info', `OAuth server running on port: ${port}`);
Expand Down Expand Up @@ -362,7 +335,7 @@ async function startSyncServer() {
return Promise.race([syncServerPromise, syncServerTimeout]); // Either the server has started or the timeout is reached
}

async function exposeSyncServer(ngrokConfig: GlobalPrefs['ngrokConfig']) {
async function exposeSyncServer(ngrokConfig: GlobalPrefsJson['ngrokConfig']) {
const hasRequiredConfig =
ngrokConfig?.authToken && ngrokConfig?.domain && ngrokConfig?.port;

Expand Down Expand Up @@ -672,7 +645,7 @@ ipcMain.handle(
export type SaveFileDialogPayload = {
title: SaveDialogOptions['title'];
defaultPath?: SaveDialogOptions['defaultPath'];
fileContents: string | NodeJS.ArrayBufferView;
fileContents: string | Buffer;
};

ipcMain.handle(
Expand All @@ -685,7 +658,11 @@ ipcMain.handle(

return new Promise<void>((resolve, reject) => {
if (fileLocation) {
fs.writeFile(fileLocation.filePath, fileContents, error => {
const contents =
typeof fileContents === 'string'
? fileContents
: new Uint8Array(fileContents.buffer);
fs.writeFile(fileLocation.filePath, contents, error => {
return reject(error);
});
}
Expand All @@ -702,7 +679,7 @@ ipcMain.handle('start-actual-server', async () => startSyncServer());

ipcMain.handle(
'expose-actual-server',
async (_event, payload: GlobalPrefs['ngrokConfig']) =>
async (_event, payload: GlobalPrefsJson['ngrokConfig']) =>
exposeSyncServer(payload),
);

Expand Down
10 changes: 0 additions & 10 deletions packages/desktop-electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ contextBridge.exposeInMainWorld('Actual', {
ipcRenderer.invoke('open-external-url', url);
},

startActualServer: (releaseVersion: string) => {
return ipcRenderer.invoke('start-actual-server', {
releaseVersion,
});
},

exposeActualServer: (settings: GlobalPrefs['ngrokConfig']) => {
return ipcRenderer.invoke('expose-actual-server', settings);
},

onEventFromMain: (type: string, handler: (...args: unknown[]) => void) => {
ipcRenderer.on(type, handler);
},
Expand Down
6 changes: 0 additions & 6 deletions packages/loot-core/typings/window.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import type { GlobalPrefs } from 'loot-core/types/prefs';

export {};

type Actual = {
IS_DEV: boolean;
ACTUAL_VERSION: string;
openURLInBrowser: (url: string) => void;
startActualServer: (releaseVersion: string) => Promise<void>;
exposeActualServer: (
settings: GlobalPrefs['ngrokConfig'],
) => Promise<{ url?: string; error?: string } | undefined>;
saveFile: (
contents: string | Buffer,
filename: string,
Expand Down

0 comments on commit c3f1600

Please sign in to comment.