mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor: app init event (#17937)
This commit is contained in:
parent
895b2bf5cd
commit
7f69abbf0d
19 changed files with 81 additions and 75 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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': [];
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue