-
Notifications
You must be signed in to change notification settings - Fork 1.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 modal state provider, replace usage except methods #1833
Add modal state provider, replace usage except methods #1833
Conversation
const closeModal = React.useCallback(() => { | ||
let totalActiveModals = 0 | ||
setActiveModals(activeModals => { | ||
activeModals.pop() |
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.
This is mutative. We shouldn't mutate inside updaters, which need to be pure functions.
We should enable Strict Mode to catch these better.
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.
Yeah good shout, this should be improved at some point. We should also do the portaling thing we talked about.
This is just a direct port of the existing functionality, so I'd like to just leave as is until we can come back and do it right.
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.
We can make this a non-mutation now though right? Not terribly hard
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.
nice. accept with small changes
…-state-into-separate-statecontext * origin: Move invite-state to new persistence + context and replace the notifications with just showing uses in the modal (#1840) Move muted threads to new persistence + context (#1838) Move onboarding state to new persistence + reducer context (#1835) Move require alt-text to new persistence + context (#1839) Move reminders to new persisted state layer (#1834) Add persistent state provider (#1830)
opts: CropperOptions, | ||
): Promise<RNImage> { | ||
// TODO handle more opts | ||
return new Promise((resolve, reject) => { | ||
store.shell.openModal({ | ||
unstable__openModal({ |
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.
Without this hacky global I'd need to pass through 2 mobx models and into this file 🤔
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.
Actually the only reason the store
model was being passed to these methods was for that. I'm fine with this hack but we should also ditch that param at some point (can be later)
@@ -363,7 +145,7 @@ export class ShellUiModel { | |||
setupLoginModals() { | |||
this.rootStore.onSessionReady(() => { | |||
if (shouldRequestEmailConfirmation(this.rootStore.session)) { | |||
this.openModal({name: 'verify-email', showReminder: true}) | |||
unstable__openModal({name: 'verify-email', showReminder: true}) |
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.
Same idea here
/** | ||
* @deprecated DO NOT USE THIS unless you have no other choice. | ||
*/ | ||
export let unstable__openModal: (modal: Modal) => void = () => { | ||
throw new Error(`ModalContext is not initialized`) | ||
} |
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.
Hack
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.
LGTM, I think any further changes can be in followups
No description provided.