's'
This commit is contained in:
39
lib/storage.ts
Normal file
39
lib/storage.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
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')
|
||||
}
|
||||
Reference in New Issue
Block a user