mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
fix(web): prevent event manager from throwing error (#26156)
This commit is contained in:
parent
0d35231dfd
commit
f207f99e86
1 changed files with 2 additions and 2 deletions
|
|
@ -15,7 +15,7 @@ const nextId = () => count++;
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
|
|
||||||
export class BaseEventManager<Events extends EventsBase> {
|
export class BaseEventManager<Events extends EventsBase> {
|
||||||
#callbacks: EventItem<Events>[] = $state([]);
|
#callbacks: EventItem<Events>[] = $state.raw([]);
|
||||||
|
|
||||||
on(subscriptions: EventMap<Events>): () => void {
|
on(subscriptions: EventMap<Events>): () => void {
|
||||||
const cleanups = Object.entries(subscriptions).map(([event, callback]) =>
|
const cleanups = Object.entries(subscriptions).map(([event, callback]) =>
|
||||||
|
|
@ -36,7 +36,7 @@ export class BaseEventManager<Events extends EventsBase> {
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const item = { id: nextId(), event, callback } as EventItem<Events, any>;
|
const item = { id: nextId(), event, callback } as EventItem<Events, any>;
|
||||||
this.#callbacks.push(item);
|
this.#callbacks = [...this.#callbacks, item];
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
this.#callbacks = this.#callbacks.filter((current) => current.id !== item.id);
|
this.#callbacks = this.#callbacks.filter((current) => current.id !== item.id);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue