State layer cleanup: move alt-text-required into preferences and fix a bug in reminders (#1845)

* Move alt-text-required into preferences

* Fix bug: reminders now using new onboarding state
zio/stable
Paul Frazee 2023-11-08 09:46:07 -08:00 committed by GitHub
parent 5843e212c0
commit 5eadadffbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 29 deletions

View File

@ -362,12 +362,7 @@ export class ShellUiModel {
setupLoginModals() { setupLoginModals() {
this.rootStore.onSessionReady(() => { this.rootStore.onSessionReady(() => {
if ( if (shouldRequestEmailConfirmation(this.rootStore.session)) {
shouldRequestEmailConfirmation(
this.rootStore.session,
this.rootStore.onboarding,
)
) {
this.openModal({name: 'verify-email', showReminder: true}) this.openModal({name: 'verify-email', showReminder: true})
setEmailConfirmationRequested() setEmailConfirmationRequested()
} }

View File

@ -1,8 +1,17 @@
import React from 'react' import React from 'react'
import {Provider as LanguagesProvider} from './languages' import {Provider as LanguagesProvider} from './languages'
import {Provider as AltTextRequiredProvider} from '../preferences/alt-text-required'
export {useLanguagePrefs, useSetLanguagePrefs} from './languages' export {useLanguagePrefs, useSetLanguagePrefs} from './languages'
export {
useRequireAltTextEnabled,
useSetRequireAltTextEnabled,
} from './alt-text-required'
export function Provider({children}: React.PropsWithChildren<{}>) { export function Provider({children}: React.PropsWithChildren<{}>) {
return <LanguagesProvider>{children}</LanguagesProvider> return (
<LanguagesProvider>
<AltTextRequiredProvider>{children}</AltTextRequiredProvider>
</LanguagesProvider>
)
} }

View File

@ -3,7 +3,6 @@ import {Provider as DrawerOpenProvider} from './drawer-open'
import {Provider as DrawerSwipableProvider} from './drawer-swipe-disabled' import {Provider as DrawerSwipableProvider} from './drawer-swipe-disabled'
import {Provider as MinimalModeProvider} from './minimal-mode' import {Provider as MinimalModeProvider} from './minimal-mode'
import {Provider as ColorModeProvider} from './color-mode' import {Provider as ColorModeProvider} from './color-mode'
import {Provider as AltTextRequiredProvider} from './alt-text-required'
import {Provider as OnboardingProvider} from './onboarding' import {Provider as OnboardingProvider} from './onboarding'
export {useIsDrawerOpen, useSetDrawerOpen} from './drawer-open' export {useIsDrawerOpen, useSetDrawerOpen} from './drawer-open'
@ -13,10 +12,6 @@ export {
} from './drawer-swipe-disabled' } from './drawer-swipe-disabled'
export {useMinimalShellMode, useSetMinimalShellMode} from './minimal-mode' export {useMinimalShellMode, useSetMinimalShellMode} from './minimal-mode'
export {useColorMode, useSetColorMode} from './color-mode' export {useColorMode, useSetColorMode} from './color-mode'
export {
useRequireAltTextEnabled,
useSetRequireAltTextEnabled,
} from './alt-text-required'
export {useOnboardingState, useOnboardingDispatch} from './onboarding' export {useOnboardingState, useOnboardingDispatch} from './onboarding'
export function Provider({children}: React.PropsWithChildren<{}>) { export function Provider({children}: React.PropsWithChildren<{}>) {
@ -25,9 +20,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
<DrawerSwipableProvider> <DrawerSwipableProvider>
<MinimalModeProvider> <MinimalModeProvider>
<ColorModeProvider> <ColorModeProvider>
<OnboardingProvider> <OnboardingProvider>{children}</OnboardingProvider>
<AltTextRequiredProvider>{children}</AltTextRequiredProvider>
</OnboardingProvider>
</ColorModeProvider> </ColorModeProvider>
</MinimalModeProvider> </MinimalModeProvider>
</DrawerSwipableProvider> </DrawerSwipableProvider>

View File

@ -1,10 +1,6 @@
import {OnboardingModel} from '../models/discovery/onboarding'
import {SessionModel} from '../models/session' import {SessionModel} from '../models/session'
export function shouldRequestEmailConfirmation( export function shouldRequestEmailConfirmation(_session: SessionModel) {
_session: SessionModel,
_onboarding: OnboardingModel,
) {
return false return false
} }

View File

@ -1,12 +1,9 @@
import * as persisted from '#/state/persisted' import * as persisted from '#/state/persisted'
import {OnboardingModel} from '../models/discovery/onboarding'
import {SessionModel} from '../models/session' import {SessionModel} from '../models/session'
import {toHashCode} from 'lib/strings/helpers' import {toHashCode} from 'lib/strings/helpers'
import {isOnboardingActive} from './onboarding'
export function shouldRequestEmailConfirmation( export function shouldRequestEmailConfirmation(session: SessionModel) {
session: SessionModel,
onboarding: OnboardingModel,
) {
const sess = session.currentSession const sess = session.currentSession
if (!sess) { if (!sess) {
return false return false
@ -14,7 +11,7 @@ export function shouldRequestEmailConfirmation(
if (sess.emailConfirmed) { if (sess.emailConfirmed) {
return false return false
} }
if (onboarding.isActive) { if (isOnboardingActive()) {
return false return false
} }
// only prompt once // only prompt once

View File

@ -49,7 +49,7 @@ import {LabelsBtn} from './labels/LabelsBtn'
import {SelectLangBtn} from './select-language/SelectLangBtn' import {SelectLangBtn} from './select-language/SelectLangBtn'
import {EmojiPickerButton} from './text-input/web/EmojiPicker.web' import {EmojiPickerButton} from './text-input/web/EmojiPicker.web'
import {insertMentionAt} from 'lib/strings/mention-manip' import {insertMentionAt} from 'lib/strings/mention-manip'
import {useRequireAltTextEnabled} from '#/state/shell' import {useRequireAltTextEnabled} from '#/state/preferences'
import { import {
useLanguagePrefs, useLanguagePrefs,
useSetLanguagePrefs, useSetLanguagePrefs,

View File

@ -50,10 +50,12 @@ import {
useSetMinimalShellMode, useSetMinimalShellMode,
useColorMode, useColorMode,
useSetColorMode, useSetColorMode,
useRequireAltTextEnabled,
useSetRequireAltTextEnabled,
useOnboardingDispatch, useOnboardingDispatch,
} from '#/state/shell' } from '#/state/shell'
import {
useRequireAltTextEnabled,
useSetRequireAltTextEnabled,
} from '#/state/preferences'
// TEMPORARY (APP-700) // TEMPORARY (APP-700)
// remove after backend testing finishes // remove after backend testing finishes