[MM-24451] Handle setting previousVersion on logout and clearing data (#4205)
* Handle setting previousVersion on login and clearing data * Fix unused import error * Update test * Just add previous version on logout
This commit is contained in:
parent
318cd13064
commit
da701268d5
3 changed files with 14 additions and 5 deletions
|
|
@ -280,6 +280,7 @@ class GlobalEventHandler {
|
|||
app: {
|
||||
build: DeviceInfo.getBuildNumber(),
|
||||
version: DeviceInfo.getVersion(),
|
||||
previousVersion: state.app?.previousVersion || DeviceInfo.getVersion(),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// See LICENSE.txt for license information.
|
||||
|
||||
import merge from 'deepmerge';
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
|
||||
function transformFromSet(incoming) {
|
||||
const state = {...incoming};
|
||||
|
|
@ -67,6 +66,7 @@ export function waitForHydration(store, callback) {
|
|||
}
|
||||
|
||||
export function getStateForReset(initialState, currentState) {
|
||||
const {app} = currentState;
|
||||
const {currentUserId} = currentState.entities.users;
|
||||
const currentUserProfile = currentState.entities.users.profiles[currentUserId];
|
||||
const {currentTeamId} = currentState.entities.teams;
|
||||
|
|
@ -78,10 +78,7 @@ export function getStateForReset(initialState, currentState) {
|
|||
});
|
||||
|
||||
const resetState = merge(initialState, {
|
||||
app: {
|
||||
build: DeviceInfo.getBuildNumber(),
|
||||
version: DeviceInfo.getVersion(),
|
||||
},
|
||||
app,
|
||||
entities: {
|
||||
users: {
|
||||
currentUserId,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@ describe('getStateForReset', () => {
|
|||
const otherUserId = 'other-user-id';
|
||||
const currentTeamId = 'current-team-id';
|
||||
const currentState = {
|
||||
app: {
|
||||
build: 'build',
|
||||
version: 'version',
|
||||
previousVersion: 'previousVersion',
|
||||
},
|
||||
entities: {
|
||||
users: {
|
||||
currentUserId,
|
||||
|
|
@ -76,4 +81,10 @@ describe('getStateForReset', () => {
|
|||
expect(themeKeys.length).not.toEqual(0);
|
||||
expect(themeKeys.length).toEqual(preferenceKeys.length);
|
||||
});
|
||||
|
||||
it('should keep app', () => {
|
||||
const resetState = getStateForReset(initialState, currentState);
|
||||
const {app} = resetState;
|
||||
expect(app).toStrictEqual(currentState.app);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue