40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import AsyncStorage from '@react-native-async-storage/async-storage'
|
|
import type { BindPayload } from './types'
|
|
|
|
const KEY = 'bind_payload_v1'
|
|
|
|
export async function loadBindPayload(): Promise<BindPayload | null> {
|
|
try {
|
|
const raw = await AsyncStorage.getItem(KEY)
|
|
if (!raw) return null
|
|
const j = JSON.parse(raw) as BindPayload
|
|
if (j.v !== 1 || !j.baseUrl) return null
|
|
return j
|
|
} catch {
|
|
return null
|
|
}
|
|
}
|
|
|
|
export async function saveBindPayload(p: BindPayload): Promise<void> {
|
|
await AsyncStorage.setItem(KEY, JSON.stringify(p))
|
|
}
|
|
|
|
export async function clearBindPayload(): Promise<void> {
|
|
await AsyncStorage.removeItem(KEY)
|
|
}
|
|
|
|
export const STORAGE_MULTI_CHANNEL_PRO = 'recording_multi_channel_pro'
|
|
|
|
export async function getMultiChannelPro(): Promise<boolean> {
|
|
try {
|
|
const v = await AsyncStorage.getItem(STORAGE_MULTI_CHANNEL_PRO)
|
|
return v === '1'
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
|
|
export async function setMultiChannelPro(on: boolean): Promise<void> {
|
|
await AsyncStorage.setItem(STORAGE_MULTI_CHANNEL_PRO, on ? '1' : '0')
|
|
}
|