Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Jan 17, 2025
1 parent bc0672e commit 42fa527
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
8 changes: 3 additions & 5 deletions packages/desktop-client/src/browser-preload.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { initBackend as initSQLBackend } from 'absurd-sql/dist/indexeddb-main-th
// eslint-disable-next-line import/no-unresolved
import { registerSW } from 'virtual:pwa-register';

import { send } from 'loot-core/platform/client/fetch';
import * as Platform from 'loot-core/src/client/platform';

import packageJson from '../package.json';
Expand Down Expand Up @@ -122,10 +121,9 @@ global.Actual = {
reader.readAsArrayBuffer(file);
reader.onload = async function (ev) {
const filepath = `/uploads/${filename}`;
send('upload-file-web', {
filename,
contents: ev.target.result,
}).then(() => resolve([filepath]));
window.__actionsForMenu
.uploadFile(filename, ev.target.result)
.then(() => resolve([filepath]));
};
reader.onerror = function () {
alert('Error reading file');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function ConfirmChangeDocumentDirModal({
const dispatch = useDispatch();

const restartElectronServer = useCallback(() => {
window.Actual.restartElectronServer();
globalThis.window.Actual.restartElectronServer();
}, []);

const [_documentDir, setDocumentDirPref] = useGlobalPref(
Expand All @@ -64,7 +64,7 @@ export function ConfirmChangeDocumentDirModal({
setLoading(true);
try {
if (moveFiles) {
await window.Actual.moveBudgetDirectory(
await globalThis.window.Actual.moveBudgetDirectory(
currentBudgetDirectory,
newDirectory,
);
Expand Down
9 changes: 9 additions & 0 deletions packages/desktop-client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ async function appFocused() {
await send('app-focused');
}

async function uploadFile(filename: string, contents: ArrayBuffer) {
send('upload-file-web', {
filename,
contents,
});
}

function inputFocused() {
return (
window.document.activeElement.tagName === 'INPUT' ||
Expand All @@ -64,6 +71,7 @@ window.__actionsForMenu = {
redo,
appFocused,
inputFocused,
uploadFile,
};

// Expose send for fun!
Expand Down Expand Up @@ -91,6 +99,7 @@ declare global {
redo: typeof redo;
appFocused: typeof appFocused;
inputFocused: typeof inputFocused;
uploadFile: typeof uploadFile;
};

$send: typeof send;
Expand Down

0 comments on commit 42fa527

Please sign in to comment.