refactor: app init event (#17937)

This commit is contained in:
Jason Rasmussen 2025-04-28 14:48:33 -04:00 committed by GitHub
parent 895b2bf5cd
commit 7f69abbf0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 81 additions and 75 deletions

View file

@ -1,9 +1,13 @@
import { goto } from '$app/navigation';
import { page } from '$app/state';
import { AppRoute } from '$lib/constants';
import { eventManager } from '$lib/managers/event-manager.svelte';
import { isSharedLinkRoute } from '$lib/utils/navigation';
import { logout } from '@immich/sdk';
class AuthManager {
key = $derived(isSharedLinkRoute(page.route?.id) ? page.params.key : undefined);
async logout() {
let redirectUri;

View file

@ -51,6 +51,7 @@ class EventManager<EventMap extends Record<string, unknown[]>> {
}
export const eventManager = new EventManager<{
'app.init': [];
'user.login': [];
'auth.login': [LoginResponseDto];
'auth.logout': [];

View file

@ -1,7 +1,12 @@
import { langs } from '$lib/constants';
import { eventManager } from '$lib/managers/event-manager.svelte';
import { lang } from '$lib/stores/preferences.store';
class LanguageManager {
constructor() {
eventManager.on('app.init', () => lang.subscribe((lang) => this.setLanguage(lang)));
}
rtl = $state(false);
setLanguage(code: string) {