Skip to content

Commit

Permalink
[native] fix handling logout action
Browse files Browse the repository at this point in the history
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
  • Loading branch information
xsanm committed Nov 2, 2023
1 parent 445632b commit 7bc50e5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions native/redux/redux-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
}

Expand Down Expand Up @@ -290,6 +292,7 @@ type FixUnreadActiveThreadResult = {
+state: AppState,
+threadStoreOperations: $ReadOnlyArray<ThreadStoreOperation>,
};

function fixUnreadActiveThread(
state: AppState,
action: *,
Expand Down Expand Up @@ -336,6 +339,7 @@ function fixUnreadActiveThread(
}

let appLastBecameInactive = 0;

function appBecameInactive() {
appLastBecameInactive = Date.now();
}
Expand Down

0 comments on commit 7bc50e5

Please sign in to comment.