Skip to content

Commit

Permalink
Try 2 to fix IPC
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdoming committed Oct 21, 2024
1 parent 4a671a2 commit 152a4fe
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 41 deletions.
7 changes: 2 additions & 5 deletions packages/desktop-client/src/components/HelpMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { forwardRef, useRef } from 'react';
import { useHotkeys } from 'react-hotkeys-hook';
import { Trans, useTranslation } from 'react-i18next';
import { useDispatch } from 'react-redux';
import { useLocation } from 'react-router-dom';

import { useToggle } from 'usehooks-ts';

import { openDocsForCurrentPage } from 'loot-core/client/actions';
import { pushModal } from 'loot-core/client/actions/modals';

import { SvgHelp } from '../icons/v2/Help';
import { getPageDocs } from '../util/help';
import { openUrl } from '../util/router-tools';

import { Button } from './common/Button2';
import { Menu } from './common/Menu';
Expand Down Expand Up @@ -52,12 +50,11 @@ export const HelpMenu = () => {
const menuButtonRef = useRef(null);

const dispatch = useDispatch();
const page = useLocation().pathname;

const handleItemSelect = (item: HelpMenuItem) => {
switch (item) {
case 'docs':
openUrl(getPageDocs(page));
dispatch(openDocsForCurrentPage());
break;
case 'keyboard-shortcuts':
dispatch(pushModal('keyboard-shortcuts'));
Expand Down
19 changes: 0 additions & 19 deletions packages/desktop-client/src/util/help.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/desktop-client/src/util/router-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@ export function ExposeNavigate() {
}, [navigate]);
return null;
}

export function openUrl(url: string) {
window.open(url, '_blank', 'noopener,noreferrer');
}
16 changes: 4 additions & 12 deletions packages/desktop-electron/menu.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import { getPageDocs } from '@actual-app/web/src/util/help';
import {
MenuItemConstructorOptions,
Menu,
ipcMain,
app,
shell,
} from 'electron';
import { MenuItemConstructorOptions, Menu, ipcMain, app } from 'electron';

export function getMenu(
isDev: boolean,
Expand Down Expand Up @@ -175,11 +168,10 @@ export function getMenu(
submenu: [
{
label: 'Documentation',
async click(_menuItem, focusedWin) {
const page = await focusedWin?.webContents.executeJavaScript(
'window.location.pathname',
click(_menuItem, focusedWin) {
focusedWin?.webContents.executeJavaScript(
'window.__actionsForMenu && window.__actionsForMenu.openDocsForCurrentPage()',
);
shell.openExternal(getPageDocs(page));
},
},
{
Expand Down
27 changes: 26 additions & 1 deletion packages/loot-core/src/client/actions/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-strict-ignore
import { send } from '../../platform/client/fetch';
import * as constants from '../constants';
import type {
Expand Down Expand Up @@ -52,3 +51,29 @@ export function reloadApp() {
global.Actual.reload();

Check failure on line 51 in packages/loot-core/src/client/actions/app.ts

View workflow job for this annotation

GitHub Actions / typecheck

Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
};
}

const getPageDocs = (page: string) => {
switch (page) {
case '/budget':
return 'https://actualbudget.org/docs/getting-started/envelope-budgeting';
case '/reports':
return 'https://actualbudget.org/docs/reports/';
case '/schedules':
return 'https://actualbudget.org/docs/schedules';
case '/payees':
return 'https://actualbudget.org/docs/transactions/payees';
case '/rules':
return 'https://actualbudget.org/docs/budgeting/rules';
case '/settings':
return 'https://actualbudget.org/docs/settings';
default:
// All pages under /accounts, plus any missing pages
return 'https://actualbudget.org/docs';
}
};

export function openDocsForCurrentPage() {
return () => {
global.Actual.openURLInBrowser(getPageDocs(window.location.pathname));

Check failure on line 77 in packages/loot-core/src/client/actions/app.ts

View workflow job for this annotation

GitHub Actions / typecheck

Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
};
}

0 comments on commit 152a4fe

Please sign in to comment.