Skip to content

Commit

Permalink
Merge branch 'master' into curmonth
Browse files Browse the repository at this point in the history
  • Loading branch information
psybers authored Aug 9, 2024
2 parents b0b5303 + 30a70f5 commit abdb824
Show file tree
Hide file tree
Showing 14 changed files with 341 additions and 70 deletions.
1 change: 1 addition & 0 deletions packages/desktop-client/src/components/Modals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export function Modals() {
key={name}
transactionIds={options?.transactionIds}
getTransaction={options?.getTransaction}
accountName={options?.accountName}
/>
);

Expand Down
1 change: 1 addition & 0 deletions packages/desktop-client/src/components/accounts/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export function AccountHeader({
</View>
) : (
<SelectedTransactionsButton
account={account}
getTransaction={id => transactions.find(t => t.id === id)}
onShow={onShowTransactions}
onDuplicate={onBatchDuplicate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,31 +206,38 @@ export function KeyboardShortcutModal() {
meta={ctrl}
/>
<Shortcut shortcut="B" description="Bank sync" meta={ctrl} />
<GroupHeading group="Select a transaction, then" />
<GroupHeading group="With transaction(s) selected" />
<Shortcut
shortcut="J"
description="Move to the next transaction down"
shortcut="F"
description="Filter to the selected transactions"
/>
<Shortcut
shortcut="K"
description="Move to the next transaction up"
shortcut="D"
description="Delete selected transactions"
/>
<Shortcut
shortcut=""
description="Move to the next transaction down and scroll"
shortcut="A"
description="Set account for selected transactions"
/>
<Shortcut
shortcut=""
description="Move to the next transaction up and scroll"
shortcut="P"
description="Set payee for selected transactions"
/>
<Shortcut
shortcut="Space"
description="Toggle selection of current transaction"
shortcut="N"
description="Set notes for selected transactions"
/>
<Shortcut
shortcut="Space"
description="Toggle all transactions between current and most recently selected transaction"
shift={true}
shortcut="C"
description="Set category for selected transactions"
/>
<Shortcut
shortcut="L"
description="Toggle cleared for selected transactions"
/>
<Shortcut
shortcut="S"
description="Link or view schedule for selected transactions"
/>
</>
)}
Expand Down Expand Up @@ -296,34 +303,31 @@ export function KeyboardShortcutModal() {
shortcut="F"
description="Filter transactions"
/>
<GroupHeading group="With transaction(s) selected" />
<GroupHeading group="Select a transaction, then" />
<Shortcut
shortcut="F"
description="Filter to the selected transactions"
shortcut="J"
description="Move to the next transaction down"
/>
<Shortcut
shortcut="D"
description="Delete selected transactions"
shortcut="K"
description="Move to the next transaction up"
/>
<Shortcut
shortcut="A"
description="Set account for selected transactions"
shortcut=""
description="Move to the next transaction down and scroll"
/>
<Shortcut
shortcut="P"
description="Set payee for selected transactions"
shortcut=""
description="Move to the next transaction up and scroll"
/>
<Shortcut
shortcut="N"
description="Set notes for selected transactions"
shortcut="Space"
description="Toggle selection of current transaction"
/>
<Shortcut
shortcut="C"
description="Set category for selected transactions"
/>
<Shortcut
shortcut="L"
description="Toggle cleared for current transaction"
shortcut="Space"
description="Toggle all transactions between current and most recently selected transaction"
shift={true}
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import { ROW_HEIGHT, SchedulesTable } from './SchedulesTable';
export function ScheduleLink({
transactionIds: ids,
getTransaction,
accountName,
}: {
transactionIds: string[];
getTransaction: (transactionId: string) => TransactionEntity;
accountName: string;
}) {
const dispatch = useDispatch();
const [filter, setFilter] = useState('');
const [filter, setFilter] = useState(accountName);

const scheduleData = useSchedules({
transform: useCallback((q: Query) => q.filter({ completed: false }), []),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Menu } from '../common/Menu';
import { SelectedItemsButton } from '../table';

export function SelectedTransactionsButton({
account,
getTransaction,
onShow,
onDuplicate,
Expand Down Expand Up @@ -112,6 +113,32 @@ export function SelectedTransactionsButton({
return areNoReconciledTransactions && areAllSplitTransactions;
}, [selectedIds, types, getTransaction]);

function onLinkSchedule() {
dispatch(
pushModal('schedule-link', {
transactionIds: selectedIds,
getTransaction,
accountName: account?.name ?? '',
}),
);
}

function onViewSchedule() {
const firstId = selectedIds[0];
let scheduleId;
if (isPreviewId(firstId)) {
const parts = firstId.split('/');
scheduleId = parts[1];
} else {
const trans = getTransaction(firstId);
scheduleId = trans && trans.schedule;
}

if (scheduleId) {
dispatch(pushModal('schedule-edit', { id: scheduleId }));
}
}

const hotKeyOptions = {
enabled: types.trans,
scopes: ['app'],
Expand Down Expand Up @@ -144,14 +171,22 @@ export function SelectedTransactionsButton({
onEdit,
selectedIds,
]);
useHotkeys(
's',
() => (!types.trans || linked ? onViewSchedule() : onLinkSchedule()),
{
scopes: ['app'],
},
[onLinkSchedule, onViewSchedule, linked, selectedIds],
);

return (
<SelectedItemsButton
name="transactions"
items={[
...(!types.trans
? [
{ name: 'view-schedule', text: 'View schedule' },
{ name: 'view-schedule', text: 'View schedule', key: 'S' },
{ name: 'post-transaction', text: 'Post transaction' },
{ name: 'skip', text: 'Skip scheduled date' },
]
Expand All @@ -168,6 +203,7 @@ export function SelectedTransactionsButton({
{
name: 'view-schedule',
text: 'View schedule',
key: 'S',
disabled: selectedIds.length > 1,
},
{ name: 'unlink-schedule', text: 'Unlink schedule' },
Expand All @@ -176,6 +212,7 @@ export function SelectedTransactionsButton({
{
name: 'link-schedule',
text: 'Link schedule',
key: 'S',
},
{
name: 'create-rule',
Expand Down Expand Up @@ -242,27 +279,10 @@ export function SelectedTransactionsButton({
onScheduleAction(name, selectedIds);
break;
case 'view-schedule':
const firstId = selectedIds[0];
let scheduleId;
if (isPreviewId(firstId)) {
const parts = firstId.split('/');
scheduleId = parts[1];
} else {
const trans = getTransaction(firstId);
scheduleId = trans && trans.schedule;
}

if (scheduleId) {
dispatch(pushModal('schedule-edit', { id: scheduleId }));
}
onViewSchedule();
break;
case 'link-schedule':
dispatch(
pushModal('schedule-link', {
transactionIds: selectedIds,
getTransaction,
}),
);
onLinkSchedule();
break;
case 'unlink-schedule':
onUnlink(selectedIds);
Expand Down
14 changes: 13 additions & 1 deletion packages/desktop-electron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,21 @@ function createBackgroundProcess() {
serverProcess = utilityProcess.fork(
__dirname + '/server.js',
['--subprocess', app.getVersion()],
isDev ? { execArgv: ['--inspect'] } : undefined,
isDev ? { execArgv: ['--inspect'], stdio: 'pipe' } : { stdio: 'pipe' },
);

serverProcess.stdout.on('data', (chunk: Buffer) => {
// Send the Server console.log messages to the main browser window
clientWin?.webContents.executeJavaScript(`
console.info('Server Log:', ${JSON.stringify(chunk.toString('utf8'))})`);
});

serverProcess.stderr.on('data', (chunk: Buffer) => {
// Send the Server console.error messages out to the main browser window
clientWin?.webContents.executeJavaScript(`
console.error('Server Log:', ${JSON.stringify(chunk.toString('utf8'))})`);
});

serverProcess.on('message', msg => {
switch (msg.type) {
case 'captureEvent':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type * as T from '.';

export const captureException: T.CaptureException = function (exc) {
console.log('[Exception]', exc);
console.error('[Exception]', exc);
};

export const captureBreadcrumb: T.CaptureBreadcrumb = function () {};
14 changes: 12 additions & 2 deletions packages/loot-core/src/platform/server/fetch/index.electron.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
// @ts-strict-ignore
export { default as fetch } from 'node-fetch';
// // @ts-strict-ignore
import nodeFetch from 'node-fetch';

export const fetch = (input: RequestInfo | URL, options?: RequestInit) => {
return nodeFetch(input, {
...options,
headers: {
...options?.headers,
origin: 'app://actual',
},
});
};
Loading

0 comments on commit abdb824

Please sign in to comment.