Fix post in channel batching order (#4090)
* Fix post in channel batching order * Preserve preferences on reset cache
This commit is contained in:
parent
fc34f34008
commit
3c73e8ec89
3 changed files with 7 additions and 15 deletions
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue