Skip to content

Commit

Permalink
UndoState type
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Jan 7, 2025
1 parent 26f67b6 commit 2601c05
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ module.exports = {
{
group: ['react-router-dom'],
importNames: ['useNavigate'],
message: 'Please import Actual’s useNavigate() hook from `src/hooks` instead.',
message:
'Please import Actual’s useNavigate() hook from `src/hooks` instead.',
},
],
},
Expand Down Expand Up @@ -502,7 +503,8 @@ module.exports = {
{
group: ['react-redux'],
importNames: ['useSelector'],
message: 'Please import Actual’s useSelector() hook from `src/redux` instead.',
message:
'Please import Actual’s useSelector() hook from `src/redux` instead.',
},
],
},
Expand Down
10 changes: 6 additions & 4 deletions packages/loot-core/src/platform/client/undo/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { OptionlessModal } from '../../../client/state-types/modals';
import { UndoState as ServerUndoState } from '../../../server/undo';
import { type ModalType } from '../../client/state-types/modals';

export type UndoState = {
id?: string;
url: string;
openModal: ModalType;
url: string | null;
// Right now, only the payees page uses this. It's only being set to
// `manage-rules` which is an optionless modal. Do we want to also
// support modals with options?
openModal: OptionlessModal | null;
selectedItems: {
name: string;
items: Set<string>;
Expand Down
8 changes: 6 additions & 2 deletions packages/loot-core/src/platform/client/undo/index.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { v4 as uuidv4 } from 'uuid';

import type * as T from '.';

type UndoStateWithId = T.UndoState & {
id?: ReturnType<typeof uuidv4>;
};

// List of recently used states. We don't use a true MRU structure
// because our needs are simple and we also do some custom reordering.
const HISTORY_SIZE = 40;
let UNDO_STATE_MRU: T.UndoState[] = [];
let UNDO_STATE_MRU: UndoStateWithId[] = [];

const currentUndoState: T.UndoState = {
const currentUndoState: UndoStateWithId = {
url: null,
openModal: null,
selectedItems: null,
Expand Down

0 comments on commit 2601c05

Please sign in to comment.