feat: more work on stores
Some checks failed
TrafficCue CI / build (push) Has been cancelled
TrafficCue CI / build-android (push) Has been cancelled
TrafficCue CI / check (push) Has been cancelled

This commit is contained in:
2025-09-26 20:08:39 +02:00
parent ed7560360f
commit 8f85d5a043

View File

@ -56,7 +56,7 @@ export const db = await openDB<TCDB>("tc", 1, {
export async function syncStores() { export async function syncStores() {
const changes = await Promise.all(await db.getAll("changes").then(changes => changes.map(async change => { const changes = await Promise.all(await db.getAll("changes").then(changes => changes.map(async change => {
const storeData = await db.get("stores", change.id); const storeData = await db.get("stores", change.id);
return { id: change.id, operation: change.operation, data: storeData?.data || null, modified_at: storeData?.modified_at || new Date().toISOString() }; return { id: change.id, operation: change.operation, data: storeData?.data || null, modified_at: storeData?.modified_at || new Date().toISOString(), type: storeData?.type || "location", name: storeData?.name || "" };
}))); })));
const stores = await db.getAll("stores").then(stores => stores.map(store => ({ id: store.id, modified_at: store.modified_at }))); const stores = await db.getAll("stores").then(stores => stores.map(store => ({ id: store.id, modified_at: store.modified_at })));
const res = await authFetch(LNV_SERVER + "/stores/sync", { const res = await authFetch(LNV_SERVER + "/stores/sync", {
@ -92,7 +92,7 @@ async function createStore(info: StoreInfo, data: object) {
const id = crypto.randomUUID(); const id = crypto.randomUUID();
const store: Store = { const store: Store = {
id, id,
name: info.name, name: info.name, // TODO: do we need a name?
type: info.type, type: info.type,
owner_id: "", // TODO owner_id: "", // TODO
data: JSON.stringify(data), data: JSON.stringify(data),