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:
parent
5eadadffbf
commit
f18b15241a
70 changed files with 634 additions and 498 deletions
|
|
@ -22,6 +22,7 @@ import {useTheme} from 'lib/ThemeContext'
|
|||
import {useAnalytics} from 'lib/analytics/analytics'
|
||||
import {cleanError} from 'lib/strings/errors'
|
||||
import {logger} from '#/logger'
|
||||
import {useModalControls} from '#/state/modals'
|
||||
|
||||
export const snapPoints = ['100%']
|
||||
|
||||
|
|
@ -30,6 +31,7 @@ export function Component({onChanged}: {onChanged: () => void}) {
|
|||
const [error, setError] = useState<string>('')
|
||||
const pal = usePalette('default')
|
||||
const {track} = useAnalytics()
|
||||
const {closeModal} = useModalControls()
|
||||
|
||||
const [isProcessing, setProcessing] = useState<boolean>(false)
|
||||
const [retryDescribeTrigger, setRetryDescribeTrigger] = React.useState<any>(
|
||||
|
|
@ -85,8 +87,8 @@ export function Component({onChanged}: {onChanged: () => void}) {
|
|||
// events
|
||||
// =
|
||||
const onPressCancel = React.useCallback(() => {
|
||||
store.shell.closeModal()
|
||||
}, [store])
|
||||
closeModal()
|
||||
}, [closeModal])
|
||||
const onPressRetryConnect = React.useCallback(
|
||||
() => setRetryDescribeTrigger({}),
|
||||
[setRetryDescribeTrigger],
|
||||
|
|
@ -110,7 +112,7 @@ export function Component({onChanged}: {onChanged: () => void}) {
|
|||
await store.agent.updateHandle({
|
||||
handle: newHandle,
|
||||
})
|
||||
store.shell.closeModal()
|
||||
closeModal()
|
||||
onChanged()
|
||||
} catch (err: any) {
|
||||
setError(cleanError(err))
|
||||
|
|
@ -127,6 +129,7 @@ export function Component({onChanged}: {onChanged: () => void}) {
|
|||
isCustom,
|
||||
onChanged,
|
||||
track,
|
||||
closeModal,
|
||||
])
|
||||
|
||||
// rendering
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue