fix(mobile): prevent crash when restoring a saved playback queue
This commit is contained in:
1 parent
c34272d508
commit
20abe20686
5 files changed
+36
-2
No files matched your search
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user