Automated cherry pick of #4090 (#4248)

* Fix post in channel batching order

* Preserve preferences on reset cache

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Mattermost Build 2020-04-30 10:21:30 +02:00 committed by GitHub
parent 8afde65922
commit ae5cdb56a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 15 deletions

View file

@ -89,10 +89,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));
@ -101,6 +97,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};

View file

@ -76,12 +76,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, {
app: {
@ -99,9 +94,7 @@ export function getStateForReset(initialState, currentState) {
teams: {
currentTeamId,
},
preferences: {
myPreferences,
},
preferences,
},
errors: currentState.errors,
views: {

View file

@ -85,8 +85,7 @@ 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);
});
it('should set previous version as current', () => {