Stop conflict checks and continuations after shutdown

This commit is contained in:
vorotamoroz committed 2026-11-04 08:19:25 +00:00
1 parent 6d811f80e1
commit d923510698
4 files changed
+389 -8

No files matched your search

@@ -6,6 +6,7 @@ import type { LogFunction } from "@vrtmrz/livesync-commonlib/compat/services/lib
import type { InjectableServiceHub } from "@vrtmrz/livesync-commonlib/compat/services/implements/injectable/InjectableServiceHub";
import { createConflictCheckingHandlers } from "./checker";
import { createConflictResolutionOperations } from "./operations";
import { EVENT_PLUGIN_UNLOADED } from "@vrtmrz/livesync-commonlib/compat/events/coreEvents";
export type ConflictResolutionHost = NecessaryServices<
"appLifecycle" | "conflict" | "database" | "replication" | "setting" | "vault",
@@ -47,6 +48,18 @@ export const useConflictResolutionFeature = createServiceFeature((host: Conflict
services.conflict.resolve.setHandler(operations.resolve);
services.conflict.resolveByNewest.setHandler(operations.resolveByNewest);
services.conflict.resolveAllConflictedFilesByNewerOnes.setHandler(operations.resolveAllConflictedFilesByNewerOnes);
const eventSubscriptions = new AbortController();
const dispose = (): void => {
checking.dispose();
operations.dispose();
eventSubscriptions.abort();
};
services.context.events.onceEvent(EVENT_PLUGIN_UNLOADED, dispose, { signal: eventSubscriptions.signal });
services.appLifecycle.onUnload.addHandler(() => {
dispose();
return Promise.resolve(true);
});
});
export { createConflictCheckingHandlers } from "./checker";