Add modal state provider, replace usage except methods (#1833)

* Add modal state provider, replace usage except methods

* Replace easy spots

* Fix sticky spots

* Replace final usages

* Memorize context objects

* Add more warnings
This commit is contained in:
Eric Bailey 2023-11-08 12:34:10 -06:00 committed by GitHub
parent 5eadadffbf
commit f18b15241a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 634 additions and 498 deletions

View file

@ -24,6 +24,7 @@ import {useTheme} from 'lib/ThemeContext'
import {useAnalytics} from 'lib/analytics/analytics'
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {cleanError, isNetworkError} from 'lib/strings/errors'
import {useModalControls} from '#/state/modals'
const MAX_NAME = 64 // todo
const MAX_DESCRIPTION = 300 // todo
@ -40,6 +41,7 @@ export function Component({
list?: ListModel
}) {
const store = useStores()
const {closeModal} = useModalControls()
const {isMobile} = useWebMediaQueries()
const [error, setError] = useState<string>('')
const pal = usePalette('default')
@ -67,8 +69,8 @@ export function Component({
const [newAvatar, setNewAvatar] = useState<RNImage | undefined | null>()
const onPressCancel = useCallback(() => {
store.shell.closeModal()
}, [store])
closeModal()
}, [closeModal])
const onSelectNewAvatar = useCallback(
async (img: RNImage | null) => {
@ -123,7 +125,7 @@ export function Component({
Toast.show(`${purposeLabel} list created`)
onSave?.(res.uri)
}
store.shell.closeModal()
closeModal()
} catch (e: any) {
if (isNetworkError(e)) {
setError(
@ -141,6 +143,7 @@ export function Component({
error,
onSave,
store,
closeModal,
activePurpose,
isCurateList,
purposeLabel,