From 7bc50e51996e380c233f46e27222960627559e51 Mon Sep 17 00:00:00 2001 From: xsanm Date: Thu, 2 Nov 2023 10:45:54 +0100 Subject: [PATCH] [native] fix handling logout action Summary: Fix for a regression introduced in D9010. The problem was that the previous code returned immediately which means `baseReducer` wasn't able to properly modify the state. Not a huge fan of this solution but I saw this somewhere in the codebase. As an alternative, I can suggest: 1. Creating a separate reducer and running it in the same place - don't think is much better, will require the same assignment. 2. Creating separate reduce and moving this to lib. Only 2 seem better than this, but don't want to put native-specific data in lib. Test Plan: Using Redux DevTools make sure that logout is handled and data that needs to be cleared is cleared/set default where it needs to be. Reviewers: ginsu, michal, tomek Reviewed By: tomek Subscribers: ashoat, wyilio Differential Revision: https://phab.comm.dev/D9674 --- native/redux/redux-setup.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js index 341b548175..9edda0b370 100644 --- a/native/redux/redux-setup.js +++ b/native/redux/redux-setup.js @@ -182,9 +182,11 @@ function reducer(state: AppState = defaultState, action: Action) { action.type === logOutActionTypes.success || action.type === deleteAccountActionTypes.success ) { - return { + state = { ...state, - localSettings: { isBackupEnabled: false }, + localSettings: { + isBackupEnabled: false, + }, }; } @@ -290,6 +292,7 @@ type FixUnreadActiveThreadResult = { +state: AppState, +threadStoreOperations: $ReadOnlyArray, }; + function fixUnreadActiveThread( state: AppState, action: *, @@ -336,6 +339,7 @@ function fixUnreadActiveThread( } let appLastBecameInactive = 0; + function appBecameInactive() { appLastBecameInactive = Date.now(); }