mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 20:44:32 -05:00
🐛 fix link-schedule option in transaction table (#1250)
Closes #1236 --------- Co-authored-by: Jed Fox <git@jedfox.com>
This commit is contained in:
committed by
GitHub
parent
d36569d258
commit
ede51872e2
@@ -7,13 +7,7 @@ import React, {
|
||||
useMemo,
|
||||
} from 'react';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import {
|
||||
Navigate,
|
||||
useParams,
|
||||
useNavigate,
|
||||
useLocation,
|
||||
useMatch,
|
||||
} from 'react-router-dom';
|
||||
import { Navigate, useParams, useLocation, useMatch } from 'react-router-dom';
|
||||
|
||||
import { debounce } from 'debounce';
|
||||
import { bindActionCreators } from 'redux';
|
||||
@@ -59,6 +53,7 @@ import SvgRemove from '../../icons/v2/Remove';
|
||||
import SearchAlternate from '../../icons/v2/SearchAlternate';
|
||||
import { authorizeBank } from '../../nordigen';
|
||||
import { styles, colors } from '../../style';
|
||||
import { usePushModal } from '../../util/router-tools';
|
||||
import { useActiveLocation } from '../ActiveLocation';
|
||||
import AnimatedRefresh from '../AnimatedRefresh';
|
||||
import {
|
||||
@@ -494,9 +489,8 @@ function SelectedTransactionsButton({
|
||||
onCreateRule,
|
||||
onScheduleAction,
|
||||
}) {
|
||||
let pushModal = usePushModal();
|
||||
let selectedItems = useSelectedItems();
|
||||
let navigate = useNavigate();
|
||||
let location = useLocation();
|
||||
|
||||
let types = useMemo(() => {
|
||||
let items = [...selectedItems];
|
||||
@@ -608,14 +602,11 @@ function SelectedTransactionsButton({
|
||||
}
|
||||
|
||||
if (scheduleId) {
|
||||
navigate(`/schedule/edit/${scheduleId}`, {
|
||||
locationPtr: location,
|
||||
});
|
||||
pushModal(`/schedule/edit/${scheduleId}`);
|
||||
}
|
||||
break;
|
||||
case 'link-schedule':
|
||||
navigate(`/schedule/link`, {
|
||||
locationPtr: location,
|
||||
pushModal('/schedule/link', {
|
||||
transactionIds: [...selectedItems],
|
||||
});
|
||||
break;
|
||||
@@ -2124,7 +2115,7 @@ export default function Account() {
|
||||
{...actionCreators}
|
||||
modalShowing={
|
||||
state.modalShowing ||
|
||||
!!(activeLocation.state && activeLocation.state.locationPtr)
|
||||
!!(activeLocation.state && activeLocation.state.parent)
|
||||
}
|
||||
accountId={params.id}
|
||||
categoryId={activeLocation?.state?.filter?.category}
|
||||
|
||||
@@ -36,14 +36,9 @@ export function handleGlobalEvents(actions, store) {
|
||||
});
|
||||
|
||||
listen('schedules-offline', ({ payees }) => {
|
||||
let navigate = window.__navigate;
|
||||
if (navigate) {
|
||||
navigate(`/schedule/posts-offline-notification`, {
|
||||
state: {
|
||||
locationPtr: navigate.location,
|
||||
payees,
|
||||
},
|
||||
});
|
||||
let pushModal = window.__pushModal;
|
||||
if (pushModal) {
|
||||
pushModal(`/schedule/posts-offline-notification`, { payees });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -13,9 +13,11 @@ let VERSION = Date.now();
|
||||
|
||||
export function ExposeNavigate() {
|
||||
let navigate = useNavigate();
|
||||
let pushModal = usePushModal();
|
||||
useLayoutEffect(() => {
|
||||
window.__navigate = navigate;
|
||||
}, [navigate]);
|
||||
window.__pushModal = pushModal;
|
||||
}, [navigate, pushModal]);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,8 +26,10 @@ export function usePushModal() {
|
||||
let location = useLocation();
|
||||
|
||||
return useCallback(
|
||||
(path: To) =>
|
||||
navigate(path, { state: { parent: location, _version: VERSION } }),
|
||||
(path: To, stateProps: Record<string, unknown> = {}) =>
|
||||
navigate(path, {
|
||||
state: { parent: location, _version: VERSION, ...stateProps },
|
||||
}),
|
||||
[navigate, location],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -131,9 +131,7 @@ function getMenu(isDev, createWindow) {
|
||||
enabled: false,
|
||||
click: function (menuItem, focusedWin) {
|
||||
focusedWin.webContents.executeJavaScript(
|
||||
// TODO: fix
|
||||
// '__navigate && __history.push("/schedule/discover", { locationPtr: __history.location })',
|
||||
'alert("Not implemented")',
|
||||
'__pushModal && __pushModal("/schedule/discover")',
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
3
packages/loot-core/typings/window.d.ts
vendored
3
packages/loot-core/typings/window.d.ts
vendored
@@ -1,3 +1,5 @@
|
||||
import { usePushModal } from '../../desktop-client/src/util/router-tools';
|
||||
|
||||
export {};
|
||||
|
||||
declare global {
|
||||
@@ -9,5 +11,6 @@ declare global {
|
||||
};
|
||||
|
||||
__navigate?: import('react-router').NavigateFunction;
|
||||
__pushModal?: ReturnType<typeof usePushModal>;
|
||||
}
|
||||
}
|
||||
|
||||
6
upcoming-release-notes/1250.md
Normal file
6
upcoming-release-notes/1250.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Bugfix
|
||||
authors: [MatissJanis]
|
||||
---
|
||||
|
||||
Fix `link schedule` option in transaction table
|
||||
6
upcoming-release-notes/1256.md
Normal file
6
upcoming-release-notes/1256.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Maintenance
|
||||
authors: [j-f1]
|
||||
---
|
||||
|
||||
Remove lingering references to `locationPtr` after `react-router` upgrade
|
||||
Reference in New Issue
Block a user