From f54671f22558d6df03f260ade89f6bbe319828f0 Mon Sep 17 00:00:00 2001 From: Andrey Mikhadyuk Date: Wed, 29 Nov 2023 15:11:20 +0400 Subject: [PATCH] remove previous breadcrumbs related logic --- src/pages/commonFeed/CommonFeedPage.tsx | 2 +- .../components/Navigation/Navigation.tsx | 18 +----------------- .../states/multipleSpacesLayout/actions.ts | 4 ++-- .../states/multipleSpacesLayout/constants.ts | 2 +- .../states/multipleSpacesLayout/reducer.ts | 6 +----- .../states/multipleSpacesLayout/selectors.ts | 4 ---- src/store/states/multipleSpacesLayout/types.ts | 1 - src/store/transforms.ts | 1 - 8 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/pages/commonFeed/CommonFeedPage.tsx b/src/pages/commonFeed/CommonFeedPage.tsx index e5feeb8e05..233a90a473 100644 --- a/src/pages/commonFeed/CommonFeedPage.tsx +++ b/src/pages/commonFeed/CommonFeedPage.tsx @@ -95,7 +95,7 @@ const CommonFeedPage: FC = () => { useEffect(() => { return () => { - dispatch(multipleSpacesLayoutActions.moveBreadcrumbsToPrevious()); + dispatch(multipleSpacesLayoutActions.clearBreadcrumbs()); }; }, []); diff --git a/src/shared/layouts/MultipleSpacesLayout/components/Header/components/Navigation/Navigation.tsx b/src/shared/layouts/MultipleSpacesLayout/components/Header/components/Navigation/Navigation.tsx index c61c9e1224..0133191d91 100644 --- a/src/shared/layouts/MultipleSpacesLayout/components/Header/components/Navigation/Navigation.tsx +++ b/src/shared/layouts/MultipleSpacesLayout/components/Header/components/Navigation/Navigation.tsx @@ -16,10 +16,6 @@ import { CommonSidenavLayoutTab, getActiveLayoutTab, } from "@/shared/layouts/CommonSidenavLayout"; -import { - selectMultipleSpacesLayoutBreadcrumbs, - selectMultipleSpacesLayoutPreviousBreadcrumbs, -} from "@/store/states"; import { CreateCommonPrompt, NavigationItem } from "./components"; import { NavigationItemOptions } from "./types"; import styles from "./Navigation.module.scss"; @@ -41,24 +37,12 @@ const Navigation: FC = (props) => { const userStreamsWithNotificationsAmount = useSelector( selectUserStreamsWithNotificationsAmount(), ); - const currentBreadcrumbs = useSelector(selectMultipleSpacesLayoutBreadcrumbs); - const previousBreadcrumbs = useSelector( - selectMultipleSpacesLayoutPreviousBreadcrumbs, - ); const user = useSelector(selectUser()); const userId = user?.uid; const { data: userCommonIds } = useUserCommonIds(); const { data: userActivity } = useUserActivity(userId); - const breadcrumbs = previousBreadcrumbs || currentBreadcrumbs; - const breadcrumbsCommonId = - breadcrumbs?.type === InboxItemType.FeedItemFollow - ? breadcrumbs.activeCommonId - : ""; const mySpacesCommonId = - breadcrumbsCommonId || - userActivity?.lastVisitedCommon || - userCommonIds[0] || - ""; + userActivity?.lastVisitedCommon || userCommonIds[0] || ""; const mySpacesPagePath = ( mySpacesCommonId ? getCommonPagePath(mySpacesCommonId) : "" ) as ROUTE_PATHS; diff --git a/src/store/states/multipleSpacesLayout/actions.ts b/src/store/states/multipleSpacesLayout/actions.ts index cb8210e550..251514f6d0 100644 --- a/src/store/states/multipleSpacesLayout/actions.ts +++ b/src/store/states/multipleSpacesLayout/actions.ts @@ -36,8 +36,8 @@ export const setBreadcrumbsData = createStandardAction( MultipleSpacesLayoutActionType.SET_BREADCRUMBS_DATA, )(); -export const moveBreadcrumbsToPrevious = createStandardAction( - MultipleSpacesLayoutActionType.MOVE_BREADCRUMBS_TO_PREVIOUS, +export const clearBreadcrumbs = createStandardAction( + MultipleSpacesLayoutActionType.CLEAR_BREADCRUMBS, )(); export const addOrUpdateProjectInBreadcrumbs = createStandardAction( diff --git a/src/store/states/multipleSpacesLayout/constants.ts b/src/store/states/multipleSpacesLayout/constants.ts index 7c5574dedb..6811fa17ad 100644 --- a/src/store/states/multipleSpacesLayout/constants.ts +++ b/src/store/states/multipleSpacesLayout/constants.ts @@ -10,7 +10,7 @@ export enum MultipleSpacesLayoutActionType { SET_BREADCRUMBS_DATA = "@MULTIPLE_SPACES_LAYOUT/SET_BREADCRUMBS_DATA", - MOVE_BREADCRUMBS_TO_PREVIOUS = "@MULTIPLE_SPACES_LAYOUT/MOVE_BREADCRUMBS_TO_PREVIOUS", + CLEAR_BREADCRUMBS = "@MULTIPLE_SPACES_LAYOUT/CLEAR_BREADCRUMBS", ADD_OR_UPDATE_PROJECT_IN_BREADCRUMBS = "@MULTIPLE_SPACES_LAYOUT/ADD_OR_UPDATE_PROJECT_IN_BREADCRUMBS", diff --git a/src/store/states/multipleSpacesLayout/reducer.ts b/src/store/states/multipleSpacesLayout/reducer.ts index 25fd6537ec..a05f3f182e 100644 --- a/src/store/states/multipleSpacesLayout/reducer.ts +++ b/src/store/states/multipleSpacesLayout/reducer.ts @@ -10,7 +10,6 @@ type Action = ActionType; const initialState: MultipleSpacesLayoutState = { breadcrumbs: null, - previousBreadcrumbs: null, backUrl: null, mainWidth: window.innerWidth, }; @@ -49,11 +48,8 @@ export const reducer = createReducer( nextState.breadcrumbs = payload && { ...payload }; }), ) - .handleAction(actions.moveBreadcrumbsToPrevious, (state) => + .handleAction(actions.clearBreadcrumbs, (state) => produce(state, (nextState) => { - nextState.previousBreadcrumbs = nextState.breadcrumbs && { - ...nextState.breadcrumbs, - }; nextState.breadcrumbs = null; }), ) diff --git a/src/store/states/multipleSpacesLayout/selectors.ts b/src/store/states/multipleSpacesLayout/selectors.ts index fff25a04d6..6c5600bd0a 100644 --- a/src/store/states/multipleSpacesLayout/selectors.ts +++ b/src/store/states/multipleSpacesLayout/selectors.ts @@ -3,10 +3,6 @@ import { AppState } from "@/shared/interfaces"; export const selectMultipleSpacesLayoutBreadcrumbs = (state: AppState) => state.multipleSpacesLayout.breadcrumbs; -export const selectMultipleSpacesLayoutPreviousBreadcrumbs = ( - state: AppState, -) => state.multipleSpacesLayout.previousBreadcrumbs; - export const selectMultipleSpacesLayoutBackUrl = (state: AppState) => state.multipleSpacesLayout.backUrl; diff --git a/src/store/states/multipleSpacesLayout/types.ts b/src/store/states/multipleSpacesLayout/types.ts index 3e2976f09f..8ba7a3534d 100644 --- a/src/store/states/multipleSpacesLayout/types.ts +++ b/src/store/states/multipleSpacesLayout/types.ts @@ -27,7 +27,6 @@ export type MultipleSpacesLayoutBreadcrumbs = export interface MultipleSpacesLayoutState { breadcrumbs: MultipleSpacesLayoutBreadcrumbs | null; - previousBreadcrumbs: MultipleSpacesLayoutBreadcrumbs | null; backUrl: string | null; mainWidth: number; } diff --git a/src/store/transforms.ts b/src/store/transforms.ts index 86030684a0..f407415742 100644 --- a/src/store/transforms.ts +++ b/src/store/transforms.ts @@ -99,7 +99,6 @@ export const multipleSpacesLayoutTransform = createTransform( (inboundState: MultipleSpacesLayoutState) => ({ ...inboundState, breadcrumbs: null, - previousBreadcrumbs: null, backUrl: null, }), (outboundState: MultipleSpacesLayoutState) => outboundState,