-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Onyx key to allow remotely resetting client data #38196
Changes from 6 commits
fa716a9
9e285f6
692092f
356e38a
be7b69a
b38eb55
3cd178a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import * as ReportActionsUtils from '@libs/ReportActionsUtils'; | |
import * as SessionUtils from '@libs/SessionUtils'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {OnyxKey} from '@src/ONYXKEYS'; | ||
import type {Route} from '@src/ROUTES'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type * as OnyxTypes from '@src/types/onyx'; | ||
|
@@ -77,6 +78,38 @@ Onyx.connect({ | |
}, | ||
}); | ||
|
||
const KEYS_TO_PRESERVE: OnyxKey[] = [ | ||
ONYXKEYS.ACCOUNT, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @marcaaron Was there any specific reason not to include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't think of a reason! Thanks for asking! The array of keys also predates this PR so we could also ask the author of the original PR that introduced this change. |
||
ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, | ||
ONYXKEYS.IS_LOADING_APP, | ||
ONYXKEYS.IS_SIDEBAR_LOADED, | ||
ONYXKEYS.MODAL, | ||
ONYXKEYS.NETWORK, | ||
ONYXKEYS.SESSION, | ||
ONYXKEYS.SHOULD_SHOW_COMPOSE_INPUT, | ||
ONYXKEYS.NVP_TRY_FOCUS_MODE, | ||
ONYXKEYS.PREFERRED_THEME, | ||
ONYXKEYS.NVP_PREFERRED_LOCALE, | ||
ONYXKEYS.CREDENTIALS, | ||
]; | ||
|
||
Onyx.connect({ | ||
key: ONYXKEYS.RESET_REQUIRED, | ||
callback: (isResetRequired) => { | ||
if (!isResetRequired) { | ||
return; | ||
} | ||
|
||
Onyx.clear(KEYS_TO_PRESERVE).then(() => { | ||
// Set this to false to reset the flag for this client | ||
Onyx.set(ONYXKEYS.RESET_REQUIRED, false); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-use-before-define | ||
openApp(); | ||
}); | ||
}, | ||
}); | ||
|
||
let resolveIsReadyPromise: () => void; | ||
const isReadyToOpenApp = new Promise<void>((resolve) => { | ||
resolveIsReadyPromise = resolve; | ||
|
@@ -527,4 +560,5 @@ export { | |
savePolicyDraftByNewWorkspace, | ||
createWorkspaceWithPolicyDraftAndNavigateToIt, | ||
updateLastVisitedPath, | ||
KEYS_TO_PRESERVE, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it would be a good idea to include the intention for this feature in the comment? If it's meant to be debug-only, maybe we could highlight it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the confusion experienced here I think it's a great idea to update this and explain the intention!
It's a server side way to force clients to reload in case some backend code leaves the app in a broken state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please let me know if the change looks good to you 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much better! The comment doesn't mention that it's a server-to-client pipe, but maybe that's obvious.