fix(mobile): prevent crash when restoring a saved playback queue
ci / mobile / mobile (Metro-бандл Android) (push) Successful in 1m32s
ci / ts / ts (packages + web) (push) Successful in 2m49s
release / release (версия и заметки) (push) Successful in 9s
release / android (APK в релиз) (push) Successful in 4m20s

This commit is contained in:
mrleo1nid committed 2026-10-21 18:41:48 +03:00
1 parent c34272d508
commit 20abe20686
5 files changed
+36 -2

No files matched your search

+2 -1
View File
@@ -188,6 +188,7 @@ export class EventBuffer {
private readonly sink: EventSink,
private readonly now: () => number = Date.now,
private readonly maxRetryMs = 5 * 60_000,
private readonly createId: (now: number) => string = uuidv7,
) {}
get pending(): readonly PlayEvent[] {
@@ -196,7 +197,7 @@ export class EventBuffer {
push(e: Omit<PlayEvent, 'id' | 'occurred_at'> & Partial<Pick<PlayEvent, 'id' | 'occurred_at'>>) {
const t = this.now();
this.queue.push({ id: e.id ?? uuidv7(t), occurred_at: e.occurred_at ?? new Date(t).toISOString(), ...e } as PlayEvent);
this.queue.push({ id: e.id ?? this.createId(t), occurred_at: e.occurred_at ?? new Date(t).toISOString(), ...e } as PlayEvent);
if (this.queue.length >= 500) void this.flush();
}