diff --git a/app/actions/views/post.js b/app/actions/views/post.js index b44660716..29077f1c2 100644 --- a/app/actions/views/post.js +++ b/app/actions/views/post.js @@ -86,10 +86,6 @@ export function getPosts(channelId, page = 0, perPage = Posts.POST_CHUNK_SIZE) { const posts = Object.values(data.posts); const actions = []; - if (posts?.length || !postForChannel) { - actions.push(receivedPostsInChannel(data, channelId, page === 0, data.prev_post_id === '')); - } - if (posts?.length) { actions.push(receivedPosts(data)); const additional = await dispatch(getPostsAdditionalDataBatch(posts)); @@ -98,6 +94,10 @@ export function getPosts(channelId, page = 0, perPage = Posts.POST_CHUNK_SIZE) { } } + if (posts?.length || !postForChannel) { + actions.push(receivedPostsInChannel(data, channelId, page === 0, data.prev_post_id === '')); + } + dispatch(batchActions(actions, 'BATCH_GET_POSTS')); return {data}; diff --git a/app/store/utils.js b/app/store/utils.js index f99430dff..355616899 100644 --- a/app/store/utils.js +++ b/app/store/utils.js @@ -69,12 +69,7 @@ export function getStateForReset(initialState, currentState) { const {currentUserId} = currentState.entities.users; const currentUserProfile = currentState.entities.users.profiles[currentUserId]; const {currentTeamId} = currentState.entities.teams; - const myPreferences = {...currentState.entities.preferences.myPreferences}; - Object.keys(myPreferences).forEach((key) => { - if (!key.startsWith('theme--')) { - Reflect.deleteProperty(myPreferences, key); - } - }); + const preferences = currentState.entities.preferences; const resetState = merge(initialState, { entities: { @@ -87,9 +82,7 @@ export function getStateForReset(initialState, currentState) { teams: { currentTeamId, }, - preferences: { - myPreferences, - }, + preferences, }, }); diff --git a/app/store/utils.test.js b/app/store/utils.test.js index 305fbce97..a055a8dad 100644 --- a/app/store/utils.test.js +++ b/app/store/utils.test.js @@ -73,7 +73,6 @@ describe('getStateForReset', () => { const {myPreferences} = resetState.entities.preferences; const preferenceKeys = Object.keys(myPreferences); const themeKeys = preferenceKeys.filter((key) => key.startsWith('theme--')); - expect(themeKeys.length).not.toEqual(0); - expect(themeKeys.length).toEqual(preferenceKeys.length); + expect(themeKeys.length).toEqual(2); }); });