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() {
this.rootStore.onSessionReady(() => {
if (
shouldRequestEmailConfirmation(
this.rootStore.session,
this.rootStore.onboarding,
)
) {
if (shouldRequestEmailConfirmation(this.rootStore.session)) {
this.openModal({name: 'verify-email', showReminder: true})
setEmailConfirmationRequested()
}

View File

@ -1,8 +1,17 @@
import React from 'react'
import {Provider as LanguagesProvider} from './languages'
import {Provider as AltTextRequiredProvider} from '../preferences/alt-text-required'
export {useLanguagePrefs, useSetLanguagePrefs} from './languages'
export {
useRequireAltTextEnabled,
useSetRequireAltTextEnabled,
} from './alt-text-required'
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 MinimalModeProvider} from './minimal-mode'
import {Provider as ColorModeProvider} from './color-mode'
import {Provider as AltTextRequiredProvider} from './alt-text-required'
import {Provider as OnboardingProvider} from './onboarding'
export {useIsDrawerOpen, useSetDrawerOpen} from './drawer-open'
@ -13,10 +12,6 @@ export {
} from './drawer-swipe-disabled'
export {useMinimalShellMode, useSetMinimalShellMode} from './minimal-mode'
export {useColorMode, useSetColorMode} from './color-mode'
export {
useRequireAltTextEnabled,
useSetRequireAltTextEnabled,
} from './alt-text-required'
export {useOnboardingState, useOnboardingDispatch} from './onboarding'
export function Provider({children}: React.PropsWithChildren<{}>) {
@ -25,9 +20,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
<DrawerSwipableProvider>
<MinimalModeProvider>
<ColorModeProvider>
<OnboardingProvider>
<AltTextRequiredProvider>{children}</AltTextRequiredProvider>
</OnboardingProvider>
<OnboardingProvider>{children}</OnboardingProvider>
</ColorModeProvider>
</MinimalModeProvider>
</DrawerSwipableProvider>

View File

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

View File

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

View File

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

View File

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