Files
beenvoice-app/lib/shortcut-queue.ts
T
soconnor 355b14faef Add local iOS release pipeline, fix shortcuts, and improve invoice UX.
Enable App Store builds without EAS, iOS 18 App Intents plugins, and signing
fixes for distribution export. Add mobile invoice PDF preview, compact line
items, and more reliable shortcut deep-link handling.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-23 01:08:20 -04:00

50 lines
1.2 KiB
TypeScript

import AsyncStorage from "@react-native-async-storage/async-storage";
import type { ParsedShortcut } from "@/lib/shortcuts";
const STORAGE_KEY = "beenvoice:pending-shortcut";
let memory: ParsedShortcut | null = null;
const listeners = new Set<() => void>();
function notify() {
for (const listener of listeners) {
listener();
}
}
export async function enqueueShortcut(shortcut: ParsedShortcut): Promise<void> {
memory = shortcut;
await AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(shortcut));
notify();
}
export async function peekPendingShortcut(): Promise<ParsedShortcut | null> {
if (memory) return memory;
const raw = await AsyncStorage.getItem(STORAGE_KEY);
if (!raw) return null;
try {
memory = JSON.parse(raw) as ParsedShortcut;
return memory;
} catch {
await AsyncStorage.removeItem(STORAGE_KEY);
return null;
}
}
export async function clearPendingShortcut(): Promise<void> {
memory = null;
await AsyncStorage.removeItem(STORAGE_KEY);
}
export function subscribeShortcutQueue(listener: () => void): () => void {
listeners.add(listener);
return () => listeners.delete(listener);
}
export async function hasPendingShortcut(): Promise<boolean> {
return (await peekPendingShortcut()) != null;
}