refactor(scanner): more basic work to get the scanner just running
All checks were successful
Build and Push LST Docker Image / docker (push) Successful in 2m33s

This commit is contained in:
2026-04-19 17:20:57 -05:00
parent 3734d9daac
commit 82f8369640
19 changed files with 642 additions and 323 deletions

View File

@@ -0,0 +1 @@
export const delay = (ms: number) => new Promise((res) => setTimeout(res, ms));

View File

@@ -0,0 +1,7 @@
import { delay } from "./delay";
export const devDelay = async (ms: number) => {
if (__DEV__) {
await delay(ms);
}
};

View File

@@ -1,36 +0,0 @@
import AsyncStorage from "@react-native-async-storage/async-storage";
export type AppConfig = {
serverUrl: string;
scannerId: string;
};
const CONFIG_KEY = "scanner_app_config";
export async function saveConfig(config: AppConfig) {
await AsyncStorage.setItem(CONFIG_KEY, JSON.stringify(config));
}
export async function getConfig(): Promise<AppConfig | null> {
const raw = await AsyncStorage.getItem(CONFIG_KEY);
if (!raw) return null;
try {
return JSON.parse(raw) as AppConfig;
} catch (error) {
console.log("Error", error)
return null;
}
}
export function hasValidConfig(config: AppConfig | null) {
if (!config) return false;
return Boolean(
config.serverUrl?.trim() &&
config.scannerId?.trim()
);
}