typescript-typenfehler behoben.. npm run lint läuft nun fehlerfrei durch.
This commit is contained in:
@@ -21,7 +21,7 @@ export async function withStore<T>(mode: TxMode, fn: (store: IDBObjectStore) =>
|
||||
return new Promise((resolve, reject) => {
|
||||
const tx = db.transaction('items', mode);
|
||||
const store = tx.objectStore('items');
|
||||
let result: any;
|
||||
let result: unknown;
|
||||
const wrap = async () => {
|
||||
try { result = await fn(store); } catch (e) { reject(e); }
|
||||
};
|
||||
@@ -31,4 +31,3 @@ export async function withStore<T>(mode: TxMode, fn: (store: IDBObjectStore) =>
|
||||
tx.onabort = () => reject(tx.error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
export function notify(text: string, type: 'success'|'error') {
|
||||
// Lazy import to avoid cycle
|
||||
import('../components/ToastHost').then(({ useToast }) => {
|
||||
try {
|
||||
// This only works inside React tree; for SW-triggered, we fallback
|
||||
const evt = new CustomEvent('guest-toast', { detail: { text, type } });
|
||||
window.dispatchEvent(evt);
|
||||
} catch {}
|
||||
});
|
||||
import('../components/ToastHost')
|
||||
.then(() => {
|
||||
try {
|
||||
// This only works inside React tree; for SW-triggered, we fallback
|
||||
const evt = new CustomEvent('guest-toast', { detail: { text, type } });
|
||||
window.dispatchEvent(evt);
|
||||
} catch (error) {
|
||||
console.warn('Dispatching toast event failed', error);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('Toast module failed to load', error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@ export async function enqueue(item: Omit<QueueItem, 'id' | 'status' | 'retries'
|
||||
try {
|
||||
const reg = await navigator.serviceWorker.ready;
|
||||
(reg as ServiceWorkerRegistration & { sync?: SyncManager }).sync?.register('upload-queue');
|
||||
} catch {}
|
||||
} catch (error) {
|
||||
console.warn('Background sync registration failed', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +85,9 @@ async function attemptUpload(it: QueueItem): Promise<boolean> {
|
||||
(pct) => {
|
||||
try {
|
||||
window.dispatchEvent(new CustomEvent('queue-progress', { detail: { id: it.id, progress: pct } }));
|
||||
} catch {}
|
||||
} catch (error) {
|
||||
console.warn('Queue progress dispatch failed', error);
|
||||
}
|
||||
}
|
||||
);
|
||||
// mark my-photo-ids for "Meine"
|
||||
@@ -91,7 +95,9 @@ async function attemptUpload(it: QueueItem): Promise<boolean> {
|
||||
const raw = localStorage.getItem('my-photo-ids');
|
||||
const arr: number[] = raw ? JSON.parse(raw) : [];
|
||||
if (json.id && !arr.includes(json.id)) localStorage.setItem('my-photo-ids', JSON.stringify([json.id, ...arr]));
|
||||
} catch {}
|
||||
} catch (error) {
|
||||
console.warn('Failed to persist my-photo-ids', error);
|
||||
}
|
||||
notify('Upload erfolgreich', 'success');
|
||||
return true;
|
||||
} catch {
|
||||
|
||||
@@ -5,7 +5,7 @@ export async function createUpload(
|
||||
it: QueueItem,
|
||||
deviceId: string,
|
||||
onProgress?: (percent: number) => void
|
||||
): Promise<any> {
|
||||
): Promise<Record<string, unknown>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', url, true);
|
||||
@@ -22,7 +22,12 @@ export async function createUpload(
|
||||
};
|
||||
xhr.onload = () => {
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
try { resolve(JSON.parse(xhr.responseText)); } catch { resolve({}); }
|
||||
try {
|
||||
resolve(JSON.parse(xhr.responseText));
|
||||
} catch (error) {
|
||||
console.warn('Upload response parse failed', error);
|
||||
resolve({});
|
||||
}
|
||||
} else {
|
||||
reject(new Error('upload failed'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user