Automated cherry pick of #4225 (#4228)

* MM-24451 Set prev app version to current on logout/reset cache

* Fix unit tests for master

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Mattermost Build 2020-04-24 20:17:07 +02:00 committed by GitHub
parent 43c42caba7
commit f4e180d339
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View file

@ -279,7 +279,7 @@ class GlobalEventHandler {
app: {
build: DeviceInfo.getBuildNumber(),
version: DeviceInfo.getVersion(),
previousVersion: state.app?.previousVersion || DeviceInfo.getVersion(),
previousVersion: DeviceInfo.getVersion(),
},
entities: {
...initialState.entities,

View file

@ -86,7 +86,10 @@ export function getStateForReset(initialState, currentState) {
});
const resetState = merge(initialState, {
app,
app: {
...app,
previousVersion: DeviceInfo.getVersion(),
},
entities: {
general: currentState.entities.general,
users: {

View file

@ -1,6 +1,8 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import DeviceInfo from 'react-native-device-info';
import initialState from '@store/initial_state';
import {getStateForReset} from '@store/utils';
@ -21,8 +23,8 @@ describe('getStateForReset', () => {
const currentTeamId = 'current-team-id';
const currentState = {
app: {
build: 'build',
version: 'version',
build: DeviceInfo.getBuildNumber(),
version: DeviceInfo.getVersion(),
previousVersion: 'previousVersion',
},
entities: {
@ -87,9 +89,9 @@ describe('getStateForReset', () => {
expect(themeKeys.length).toEqual(preferenceKeys.length);
});
it('should keep app', () => {
it('should set previous version as current', () => {
const resetState = getStateForReset(initialState, currentState);
const {app} = resetState;
expect(app).toStrictEqual(currentState.app);
expect(app.previousVersion).toStrictEqual(currentState.app.version);
});
});