* refactor swing animation to controller * idle animator!!!! * implelment state switch transition * a huge fix for UI server edit! * adjust ui scaling so main menu elements clip less * view bobbing, new config name, ws: * EXTREMELY important fixes to entities rendering * a lot of fixes, add dns resolve fallback * improve f3 E, fix modal not found edge case * set correctly target for old browsers, should fix ios 14 crash * unecessary big refactor, to fix ts err * fix isWysiwyg check * fix entities rendering count
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { proxy, subscribe, useSnapshot } from 'valtio'
|
|
import { activeModalStack, hideCurrentModal } from '../globalState'
|
|
import Screen from './Screen'
|
|
import Button from './Button'
|
|
import { hardcodedKnownModals, watchedModalsFromHooks } from './utilsApp'
|
|
|
|
const componentActive = proxy({
|
|
enabled: false
|
|
})
|
|
|
|
const checkModalAvailability = () => {
|
|
const last = activeModalStack.at(-1)
|
|
let withWildCardModal = false
|
|
for (const modal of watchedModalsFromHooks.value) {
|
|
if (modal.endsWith('*') && last?.reactType.startsWith(modal.slice(0, -1))) {
|
|
withWildCardModal = true
|
|
break
|
|
}
|
|
}
|
|
|
|
componentActive.enabled = !!last && !hardcodedKnownModals.some(x => last.reactType.startsWith(x)) && !watchedModalsFromHooks.value.has(last.reactType) && !withWildCardModal
|
|
}
|
|
|
|
subscribe(activeModalStack, () => {
|
|
checkModalAvailability()
|
|
})
|
|
subscribe(watchedModalsFromHooks, () => {
|
|
checkModalAvailability()
|
|
})
|
|
|
|
export default () => {
|
|
const { enabled } = useSnapshot(componentActive)
|
|
const lastModal = useSnapshot(activeModalStack).at(-1)?.reactType
|
|
|
|
if (!enabled) return null
|
|
return <Screen
|
|
title={`Error: Modal (route) ${lastModal} is is unavailable or doesn't exist`}
|
|
style={{
|
|
zIndex: -1,
|
|
}}
|
|
backdrop={false}
|
|
>
|
|
<Button
|
|
style={{ marginTop: 30 }} onClick={() => {
|
|
hideCurrentModal()
|
|
}}
|
|
>Back
|
|
</Button>
|
|
</Screen>
|
|
}
|