-
Notifications
You must be signed in to change notification settings - Fork 132
Add redux persist to web; use for library categories C-3125 C-3220 #6354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| import { Storage, persistReducer } from 'redux-persist' | ||
|
|
||
| import { ID } from 'models/Identifiers' | ||
| import { asLineup } from 'store/lineup/reducer' | ||
| import { | ||
|
|
@@ -11,8 +13,6 @@ import { | |
| FETCH_SAVES_FAILED, | ||
| FETCH_SAVES_REQUESTED, | ||
| FETCH_SAVES_SUCCEEDED, | ||
| INIT_COLLECTIONS_CATEGORY_FROM_LOCAL_STORAGE, | ||
| INIT_TRACKS_CATEGORY_FROM_LOCAL_STORAGE, | ||
| REMOVE_LOCAL_COLLECTION, | ||
| REMOVE_LOCAL_TRACK, | ||
| SET_SELECTED_CATEGORY | ||
|
|
@@ -201,18 +201,6 @@ const actionsMap: ActionsMap<SavedPageState> = { | |
| }) | ||
| } | ||
| }, | ||
| [INIT_TRACKS_CATEGORY_FROM_LOCAL_STORAGE](state, action) { | ||
| return { | ||
| ...state, | ||
| tracksCategory: action.category | ||
| } | ||
| }, | ||
| [INIT_COLLECTIONS_CATEGORY_FROM_LOCAL_STORAGE](state, action) { | ||
| return { | ||
| ...state, | ||
| collectionsCategory: action.category | ||
| } | ||
| }, | ||
| [signOut.type]() { | ||
| return initialState | ||
| } | ||
|
|
@@ -229,4 +217,12 @@ const reducer = (state = initialState, action: any) => { | |
| return matchingReduceFunction(state, action) | ||
| } | ||
|
|
||
| export default reducer | ||
| export const savedPagePersistConfig = (storage: Storage) => ({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nicee |
||
| key: 'saved-page', | ||
| storage, | ||
| whitelist: ['tracksCategory', 'collectionsCategory'] | ||
| }) | ||
|
|
||
| export const persistedSavePageReducer = (storage: Storage) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pure functionss |
||
| return persistReducer(savedPagePersistConfig(storage), reducer) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { | |
| reducers as commonReducers, | ||
| chatMiddleware | ||
| } from '@audius/common' | ||
| import AsyncStorage from '@react-native-async-storage/async-storage' | ||
| import backend from 'audius-client/src/common/store/backend/reducer' | ||
| import type { BackendState } from 'audius-client/src/common/store/backend/types' | ||
| import searchBar from 'audius-client/src/common/store/search-bar/reducer' | ||
|
|
@@ -105,7 +106,7 @@ const onSagaError = ( | |
| } | ||
| } | ||
|
|
||
| const commonStoreReducers = commonReducers() | ||
| const commonStoreReducers = commonReducers(AsyncStorage) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice, i love how this is implemented |
||
|
|
||
| const rootReducer = combineReducers({ | ||
| ...commonStoreReducers, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool this can go away too