Skip to content

Commit

Permalink
remove previous breadcrumbs related logic
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Nov 29, 2023
1 parent 17a2840 commit f54671f
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/pages/commonFeed/CommonFeedPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const CommonFeedPage: FC = () => {

useEffect(() => {
return () => {
dispatch(multipleSpacesLayoutActions.moveBreadcrumbsToPrevious());
dispatch(multipleSpacesLayoutActions.clearBreadcrumbs());
};
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -41,24 +37,12 @@ const Navigation: FC<NavigationProps> = (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;
Expand Down
4 changes: 2 additions & 2 deletions src/store/states/multipleSpacesLayout/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export const setBreadcrumbsData = createStandardAction(
MultipleSpacesLayoutActionType.SET_BREADCRUMBS_DATA,
)<MultipleSpacesLayoutBreadcrumbs | null>();

export const moveBreadcrumbsToPrevious = createStandardAction(
MultipleSpacesLayoutActionType.MOVE_BREADCRUMBS_TO_PREVIOUS,
export const clearBreadcrumbs = createStandardAction(
MultipleSpacesLayoutActionType.CLEAR_BREADCRUMBS,
)();

export const addOrUpdateProjectInBreadcrumbs = createStandardAction(
Expand Down
2 changes: 1 addition & 1 deletion src/store/states/multipleSpacesLayout/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
6 changes: 1 addition & 5 deletions src/store/states/multipleSpacesLayout/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type Action = ActionType<typeof actions>;

const initialState: MultipleSpacesLayoutState = {
breadcrumbs: null,
previousBreadcrumbs: null,
backUrl: null,
mainWidth: window.innerWidth,
};
Expand Down Expand Up @@ -49,11 +48,8 @@ export const reducer = createReducer<MultipleSpacesLayoutState, Action>(
nextState.breadcrumbs = payload && { ...payload };
}),
)
.handleAction(actions.moveBreadcrumbsToPrevious, (state) =>
.handleAction(actions.clearBreadcrumbs, (state) =>
produce(state, (nextState) => {
nextState.previousBreadcrumbs = nextState.breadcrumbs && {
...nextState.breadcrumbs,
};
nextState.breadcrumbs = null;
}),
)
Expand Down
4 changes: 0 additions & 4 deletions src/store/states/multipleSpacesLayout/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion src/store/states/multipleSpacesLayout/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export type MultipleSpacesLayoutBreadcrumbs =

export interface MultipleSpacesLayoutState {
breadcrumbs: MultipleSpacesLayoutBreadcrumbs | null;
previousBreadcrumbs: MultipleSpacesLayoutBreadcrumbs | null;
backUrl: string | null;
mainWidth: number;
}
Expand Down
1 change: 0 additions & 1 deletion src/store/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export const multipleSpacesLayoutTransform = createTransform(
(inboundState: MultipleSpacesLayoutState) => ({
...inboundState,
breadcrumbs: null,
previousBreadcrumbs: null,
backUrl: null,
}),
(outboundState: MultipleSpacesLayoutState) => outboundState,
Expand Down

0 comments on commit f54671f

Please sign in to comment.