()
| 3 | import { getZenBridge } from '@zennotes/bridge-contract/bridge' |
| 4 | |
| 5 | export function useAppUpdateState(): AppUpdateState | null { |
| 6 | const [state, setState] = useState<AppUpdateState | null>(null) |
| 7 | |
| 8 | useEffect(() => { |
| 9 | const zen = getZenBridge() |
| 10 | let cancelled = false |
| 11 | |
| 12 | void zen.getAppUpdateState().then( |
| 13 | (next) => { |
| 14 | if (!cancelled) setState(next) |
| 15 | }, |
| 16 | () => { |
| 17 | if (!cancelled) setState(null) |
| 18 | } |
| 19 | ) |
| 20 | |
| 21 | const unsubscribe = zen.onAppUpdateState((next) => { |
| 22 | if (!cancelled) setState(next) |
| 23 | }) |
| 24 | |
| 25 | return () => { |
| 26 | cancelled = true |
| 27 | unsubscribe() |
| 28 | } |
| 29 | }, []) |
| 30 | |
| 31 | return state |
| 32 | } |
| 33 | |
| 34 | export function appUpdateBadgeLabel(state: AppUpdateState | null): string | null { |
| 35 | switch (state?.phase) { |
no test coverage detected