Persisting conversation pin statuses.

pull/1745/head
Warrick Corfe-Tan 4 years ago
parent 60b3032833
commit 264f97663e

@ -411,5 +411,7 @@
"audioMessageAutoplayDescription": "Automatically play consecutively sent audio messages", "audioMessageAutoplayDescription": "Automatically play consecutively sent audio messages",
"clickToTrustContact": "Click to download media", "clickToTrustContact": "Click to download media",
"trustThisContactDialogTitle": "Trust $name$?", "trustThisContactDialogTitle": "Trust $name$?",
"trustThisContactDialogDescription": "Are you sure you want to download media sent by $name$?" "trustThisContactDialogDescription": "Are you sure you want to download media sent by $name$?",
"pinConversation": "Pin Conversation",
"unpinConversation": "Unpin Conversation"
} }

@ -141,8 +141,8 @@ export const MenuItemPinConversation = (props: PinConversationMenuItemProps): JS
isPinned: !isPinned isPinned: !isPinned
})) }))
} }
const menuText = isPinned ? window.i18n('unpinConversation'): window.i18n('pinConversation');
return <Item onClick={togglePinConversation}>{(isPinned ? 'Unpin' : 'Pin') + ' Conversation'}</Item> return <Item onClick={togglePinConversation}>{menuText}</Item>
} }
export function getDeleteContactMenuItem( export function getDeleteContactMenuItem(

@ -6,7 +6,6 @@ import { persistReducer } from 'redux-persist';
// tslint:disable-next-line: no-submodule-imports match-default-export-name // tslint:disable-next-line: no-submodule-imports match-default-export-name
import storage from 'redux-persist/lib/storage'; import storage from 'redux-persist/lib/storage';
import purgeStoredState from 'redux-persist/es/purgeStoredState';
// @ts-ignore // @ts-ignore
const env = window.getEnvironment(); const env = window.getEnvironment();
@ -30,7 +29,7 @@ const logger = createLogger({
export const persistConfig = { export const persistConfig = {
key: 'root', key: 'root',
storage, storage,
whitelist: ['userConfig', 'conversations'], whitelist: ['userConfig']
}; };
const persistedReducer = persistReducer(persistConfig, allReducers); const persistedReducer = persistReducer(persistConfig, allReducers);
@ -41,7 +40,6 @@ const middlewareList = disableLogging ? [promise] : [promise, logger];
export const createStore = (initialState: any) => export const createStore = (initialState: any) =>
configureStore({ configureStore({
// reducer: allReducers,
reducer: persistedReducer, reducer: persistedReducer,
preloadedState: initialState, preloadedState: initialState,
middleware: (getDefaultMiddleware: any) => getDefaultMiddleware().concat(middlewareList), middleware: (getDefaultMiddleware: any) => getDefaultMiddleware().concat(middlewareList),

@ -14,6 +14,10 @@ import { defaultOnionReducer as onionPaths, OnionState } from './ducks/onion';
import { modalReducer as modals, ModalState } from './ducks/modalDialog'; import { modalReducer as modals, ModalState } from './ducks/modalDialog';
import { userConfigReducer as userConfig, UserConfigState } from './ducks/userConfig'; import { userConfigReducer as userConfig, UserConfigState } from './ducks/userConfig';
// tslint:disable-next-line: no-submodule-imports match-default-export-name
import storage from 'redux-persist/lib/storage';
import persistReducer from 'redux-persist/lib/persistReducer';
export type StateType = { export type StateType = {
search: SearchStateType; search: SearchStateType;
user: UserStateType; user: UserStateType;
@ -27,9 +31,15 @@ export type StateType = {
userConfig: UserConfigState; userConfig: UserConfigState;
}; };
const conversationsPersistConfig = {
key: 'conversations',
storage,
whitelist: ['conversationLookup']
}
export const reducers = { export const reducers = {
search, search,
conversations, conversations: persistReducer(conversationsPersistConfig, conversations),
user, user,
theme, theme,
section, section,

Loading…
Cancel
Save