feat: Track navigation path when switching between cards

This commit is contained in:
Maksim Eltyshev
2025-07-31 16:59:16 +02:00
parent a37a6b45b1
commit 0049ba2145
6 changed files with 69 additions and 5 deletions
+14
View File
@@ -16,7 +16,9 @@ const initialState = {
isEditModeEnabled: false,
modal: null,
boardId: null,
cardId: null,
recentCardId: null,
prevCardIds: [],
homeView: HomeViews.GROUPED_PROJECTS,
projectsSearch: '',
projectsOrder: ProjectOrders.BY_DEFAULT,
@@ -37,6 +39,7 @@ export default (state = initialState, { type, payload }) => {
...state,
isContentFetching: false,
boardId: payload.currentBoardId,
cardId: payload.currentCardId,
};
if (payload.currentCardId) {
@@ -45,6 +48,17 @@ export default (state = initialState, { type, payload }) => {
nextState.recentCardId = null;
}
if (payload.currentCardId) {
if (state.cardId) {
nextState.prevCardIds =
payload.currentCardId === nextState.prevCardIds.at(-1)
? [...nextState.prevCardIds.slice(0, -1)]
: [...nextState.prevCardIds, state.cardId];
}
} else if (nextState.prevCardIds.length > 0) {
nextState.prevCardIds = [];
}
if (payload.isEditModeEnabled !== undefined) {
nextState.isEditModeEnabled = payload.isEditModeEnabled;
}