Skip to content

Commit

Permalink
add transform for multiple spaces layout
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Nov 29, 2023
1 parent 0e60480 commit 5d156d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/store/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
inboxTransform,
lastCommonFromFeedTransform,
cacheTransform,
multipleSpacesLayoutTransform,
} from "./transforms";

const persistConfig: PersistConfig<AppState> = {
Expand All @@ -37,7 +38,12 @@ const persistConfig: PersistConfig<AppState> = {
"multipleSpacesLayout",
],
stateReconciler: autoMergeLevel2,
transforms: [inboxTransform, lastCommonFromFeedTransform, cacheTransform],
transforms: [
inboxTransform,
lastCommonFromFeedTransform,
cacheTransform,
multipleSpacesLayoutTransform,
],
};

const sagaMiddleware = createSagaMiddleware();
Expand Down
15 changes: 13 additions & 2 deletions src/store/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { createTransform } from "redux-persist";
import { deserializeFeedLayoutItemWithFollowData } from "@/shared/interfaces";
import { convertObjectDatesToFirestoreTimestamps } from "@/shared/utils";
import { getFeedLayoutItemDateForSorting } from "@/store/states/inbox/utils";
import { CommonLayoutState } from "./states/commonLayout";
import { CacheState } from "./states/cache";
import { CommonLayoutState } from "./states/commonLayout";
import {
InboxItems,
InboxState,
INITIAL_INBOX_ITEMS,
INITIAL_INBOX_STATE,
} from "./states/inbox";
import { MultipleSpacesLayoutState } from "./states/multipleSpacesLayout";

export const inboxTransform = createTransform(
(inboundState: InboxState) => {
Expand Down Expand Up @@ -89,7 +90,17 @@ export const cacheTransform = createTransform(
(inboundState: CacheState) => inboundState,
(outboundState: CacheState) => ({
...outboundState,
discussionMessagesStates: {}
discussionMessagesStates: {},
}),
{ whitelist: ["cache"] },
);

export const multipleSpacesLayoutTransform = createTransform(
(inboundState: MultipleSpacesLayoutState) => ({
...inboundState,
breadcrumbs: null,
backUrl: null,
}),
(outboundState: MultipleSpacesLayoutState) => outboundState,
{ whitelist: ["multipleSpacesLayout"] },
);

0 comments on commit 5d156d4

Please sign in to comment.