Skip to content

Commit

Permalink
add SignoutManager + remove bcast channel again
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed Sep 28, 2021
1 parent 7da6e74 commit f3e3f82
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 128 deletions.
65 changes: 2 additions & 63 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"@react-navigation/native": "6.0.2",
"@react-navigation/stack": "6.0.7",
"babel-plugin-transform-remove-console": "^6.9.4",
"broadcast-channel": "^4.2.0",
"dotenv": "^8.2.0",
"electron-context-menu": "^2.3.0",
"electron-log": "^4.3.5",
Expand Down
3 changes: 3 additions & 0 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,7 @@ export default {

// Stores Workspace ID that will be tied to reimbursement account during setup
REIMBURSEMENT_ACCOUNT_WORKSPACE_ID: 'reimbursementAccountWorkspaceID',

// Notifies all tabs that they should sign out and clear storage.
SHOULD_SIGN_OUT: 'shouldSignOut',
};
43 changes: 0 additions & 43 deletions src/components/SignoutManager/index.js

This file was deleted.

20 changes: 0 additions & 20 deletions src/components/SignoutManager/index.native.js

This file was deleted.

38 changes: 38 additions & 0 deletions src/libs/SignoutManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Onyx from 'react-native-onyx';
import ONYXKEYS from '../ONYXKEYS';

let signoutCallback = () => {};
let errorMessage = '';
let shouldSignOut = false;
Onyx.connect({
key: ONYXKEYS.SHOULD_SIGN_OUT,
callback: (val) => {
if (!shouldSignOut && val) {
signoutCallback(errorMessage);
errorMessage = '';
Onyx.set(ONYXKEYS.SHOULD_SIGN_OUT, false);
}

shouldSignOut = val;
},
});

/**
* @param {Function} callback
*/
function registerSignoutCallback(callback) {
signoutCallback = callback;
}

/**
* @param {String} message
*/
function signOut(message) {
errorMessage = message;
Onyx.set(ONYXKEYS.SHOULD_SIGN_OUT, true);
}

export default {
signOut,
registerSignoutCallback,
};
2 changes: 1 addition & 1 deletion src/libs/actions/SignInRedirect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Onyx from 'react-native-onyx';
import SignoutManager from '../../components/SignoutManager';
import SignoutManager from '../SignoutManager';
import ONYXKEYS from '../../ONYXKEYS';

let currentActiveClients;
Expand Down

0 comments on commit f3e3f82

Please sign in to comment.