Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try 2 to fix IPC
Browse files Browse the repository at this point in the history
jfdoming committed Oct 21, 2024
1 parent 4a671a2 commit 6165879
Showing 5 changed files with 32 additions and 40 deletions.
7 changes: 2 additions & 5 deletions packages/desktop-client/src/components/HelpMenu.tsx
Original file line number Diff line number Diff line change
@@ -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';
@@ -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'));
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
@@ -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,
@@ -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));
},
},
{
26 changes: 26 additions & 0 deletions packages/loot-core/src/client/actions/app.ts
Original file line number Diff line number Diff line change
@@ -52,3 +52,29 @@ export function reloadApp() {
global.Actual.reload();
};
}

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));
};
}

0 comments on commit 6165879

Please sign in to comment.