MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / useAppUpdateState

Function useAppUpdateState

packages/app-core/src/lib/app-update-state.ts:5–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { getZenBridge } from '@zennotes/bridge-contract/bridge'
4
5export 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
34export function appUpdateBadgeLabel(state: AppUpdateState | null): string | null {
35 switch (state?.phase) {

Callers 3

AppUpdateNoticeFunction · 0.90
SettingsModalFunction · 0.90
SidebarFunction · 0.90

Calls 3

getZenBridgeFunction · 0.90
getAppUpdateStateMethod · 0.80
onAppUpdateStateMethod · 0.80

Tested by

no test coverage detected