refactor: event manager (#25565)

This commit is contained in:
Jason Rasmussen
2026-01-29 08:52:18 -05:00
committed by GitHub
parent 8db61d341f
commit 10b53b525d
21 changed files with 84 additions and 68 deletions
@@ -37,9 +37,11 @@ class AssetCacheManager {
#ocrCache = new AsyncCache<AssetOcrResponseDto[]>();
constructor() {
eventManager.on('AssetEditsApplied', () => {
this.#assetCache.clear();
this.#ocrCache.clear();
eventManager.on({
AssetEditsApplied: () => {
this.#assetCache.clear();
this.#ocrCache.clear();
},
});
}
+3 -1
View File
@@ -59,7 +59,9 @@ class CastManager {
// Add other cast destinations here (ie FCast)
];
eventManager.on('AppInit', () => void this.initialize());
eventManager.on({
AppInit: () => void this.initialize(),
});
}
private async initialize() {
@@ -5,7 +5,9 @@ class FeatureFlagsManager {
#value?: ServerFeaturesDto = $state();
constructor() {
eventManager.on('SystemConfigUpdate', () => void this.#loadFeatureFlags());
eventManager.on({
SystemConfigUpdate: () => void this.#loadFeatureFlags(),
});
}
async init() {
@@ -4,7 +4,9 @@ import { lang } from '$lib/stores/preferences.store';
class LanguageManager {
constructor() {
eventManager.on('AppInit', () => lang.subscribe((lang) => this.setLanguage(lang)));
eventManager.on({
AppInit: () => lang.subscribe((lang) => this.setLanguage(lang)),
});
}
rtl = $state(false);
+3 -1
View File
@@ -19,7 +19,9 @@ export class QueueManager {
}
constructor() {
eventManager.on('QueueUpdate', () => this.refresh());
eventManager.on({
QueueUpdate: () => this.refresh(),
});
}
listen() {
@@ -5,7 +5,9 @@ class ReleaseManager {
value = $state<ReleaseEvent | undefined>();
constructor() {
eventManager.on('ReleaseEvent', (event) => (this.value = event));
eventManager.on({
ReleaseEvent: (event) => (this.value = event),
});
}
}
@@ -5,7 +5,9 @@ class ServerConfigManager {
#value?: ServerConfigDto = $state();
constructor() {
eventManager.on('SystemConfigUpdate', () => this.loadServerConfig());
eventManager.on({
SystemConfigUpdate: () => this.loadServerConfig(),
});
}
async init() {
@@ -7,7 +7,9 @@ class SystemConfigManager {
#defaultValue?: SystemConfigDto = $state();
constructor() {
eventManager.on('SystemConfigUpdate', (config) => (this.#value = config));
eventManager.on({
SystemConfigUpdate: (config) => (this.#value = config),
});
}
async init() {
+3 -1
View File
@@ -37,7 +37,9 @@ class ThemeManager {
isDark = $derived(this.value === Theme.DARK);
constructor() {
eventManager.on('AppInit', () => this.#onAppInit());
eventManager.on({
AppInit: () => this.#onAppInit(),
});
}
setSystem(system: boolean) {
@@ -111,9 +111,11 @@ export class TimelineManager extends VirtualScrollManager {
constructor() {
super();
const onAssetUpdate = (asset: AssetResponseDto) => this.upsertAssets([toTimelineAsset(asset)]);
this.#unsubscribes.push(eventManager.on('AssetUpdate', onAssetUpdate));
this.#unsubscribes.push(
eventManager.on({
AssetUpdate: (asset: AssetResponseDto) => this.upsertAssets([toTimelineAsset(asset)]),
}),
);
}
override get scrollTop(): number {
@@ -6,7 +6,7 @@ class UploadManager {
mediaTypes = $state<ServerMediaTypesResponseDto>({ image: [], sidecar: [], video: [] });
constructor() {
eventManager.onMany({
eventManager.on({
AppInit: () => this.#loadExtensions(),
AuthLogout: () => this.reset(),
});