mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 20:44:32 -05:00
Restore undo-url-saving behavior (#1234)
This commit is contained in:
@@ -14,6 +14,8 @@ import {
|
||||
NavLink,
|
||||
useNavigate,
|
||||
BrowserRouter,
|
||||
useLocation,
|
||||
useHref,
|
||||
} from 'react-router-dom';
|
||||
|
||||
import hotkeys from 'hotkeys-js';
|
||||
@@ -23,6 +25,7 @@ import { AccountsProvider } from 'loot-core/src/client/data-hooks/accounts';
|
||||
import { PayeesProvider } from 'loot-core/src/client/data-hooks/payees';
|
||||
import { SpreadsheetProvider } from 'loot-core/src/client/SpreadsheetProvider';
|
||||
import checkForUpdateNotification from 'loot-core/src/client/update-notification';
|
||||
import * as undo from 'loot-core/src/platform/client/undo';
|
||||
|
||||
import Cog from '../icons/v1/Cog';
|
||||
import PiggyBank from '../icons/v1/PiggyBank';
|
||||
@@ -204,7 +207,7 @@ function MobileNavTabs() {
|
||||
);
|
||||
}
|
||||
|
||||
function Redirector({ getAccounts }) {
|
||||
function RouterBehaviors({ getAccounts }) {
|
||||
let navigate = useNavigate();
|
||||
useEffect(() => {
|
||||
// Get the accounts and check if any exist. If there are no
|
||||
@@ -216,6 +219,12 @@ function Redirector({ getAccounts }) {
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
let location = useLocation();
|
||||
let href = useHref(location);
|
||||
useEffect(() => {
|
||||
undo.setUndoState('url', href);
|
||||
}, [href]);
|
||||
}
|
||||
|
||||
function FinancesApp(props) {
|
||||
@@ -240,7 +249,7 @@ function FinancesApp(props) {
|
||||
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<Redirector getAccounts={props.getAccounts} />
|
||||
<RouterBehaviors getAccounts={props.getAccounts} />
|
||||
<ExposeNavigate />
|
||||
|
||||
<View style={{ height: '100%', backgroundColor: colors.n10 }}>
|
||||
|
||||
@@ -112,8 +112,11 @@ export function handleGlobalEvents(actions, store) {
|
||||
} else {
|
||||
actions.closeModal();
|
||||
|
||||
if (window.location.href !== tagged.url) {
|
||||
window.location.href = tagged.url;
|
||||
if (
|
||||
window.location.href.replace(window.location.origin, '') !==
|
||||
tagged.url
|
||||
) {
|
||||
window.__navigate(tagged.url);
|
||||
// This stops propagation of the undo event, which is
|
||||
// important because if we are changing URLs any existing
|
||||
// undo listeners on the current page don't need to be run
|
||||
|
||||
2
packages/loot-core/typings/window.d.ts
vendored
2
packages/loot-core/typings/window.d.ts
vendored
@@ -8,6 +8,6 @@ declare global {
|
||||
openURLInBrowser: (url: string) => void;
|
||||
};
|
||||
|
||||
__navigate?: ReturnType<import('react-router')['useNavigate']>;
|
||||
__navigate?: import('react-router').NavigateFunction;
|
||||
}
|
||||
}
|
||||
|
||||
6
upcoming-release-notes/1234.md
Normal file
6
upcoming-release-notes/1234.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Bugfix
|
||||
authors: [j-f1]
|
||||
---
|
||||
|
||||
Stop page from refreshing when undoing
|
||||
Reference in New Issue
Block a user