mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
refactor: event manager (#25565)
This commit is contained in:
@@ -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();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user