File size: 1,137 Bytes
8a29801
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**

 * Cloud-client runtime status store — moved into engine so engine owns the

 * cloud-v2 runtime status (connection status + audio transport). Re-exported

 * through the host's `@/stores/cloudClientStatus` shim so the app keeps its

 * imports, and surfaced as `engine.stores.cloudClientStatus`.

 */
import {create} from "zustand"

import type {RuntimeAudioTransport, RuntimeSnapshot, RuntimeStatus} from "@mentra/cloud-client/react-native"

const initialSnapshot: RuntimeSnapshot = {
  status: "disconnected",
  audioTransport: "none",
}

export interface CloudClientStatusState extends RuntimeSnapshot {
  lastChangedAt: Date | null
  setSnapshot: (snapshot: RuntimeSnapshot) => void
  reset: () => void
}

export const useCloudClientStatusStore = create<CloudClientStatusState>((set) => ({
  ...initialSnapshot,
  lastChangedAt: null,
  setSnapshot: (snapshot) =>
    set({
      ...snapshot,
      lastChangedAt: new Date(),
    }),
  reset: () =>
    set({
      ...initialSnapshot,
      lastChangedAt: null,
    }),
}))

export type {RuntimeAudioTransport, RuntimeSnapshot, RuntimeStatus}