immich/web/src/lib/stores/user.svelte.ts
martin 8945a5d862
fix: reduce the number of API requests when changing route (#14666)
* fix: reduce the number of API requests when changing route

* fix: reset `userInteraction` after sign out
2024-12-16 08:45:01 -06:00

27 lines
683 B
TypeScript

import type {
AlbumResponseDto,
ServerAboutResponseDto,
ServerStorageResponseDto,
ServerVersionHistoryResponseDto,
} from '@immich/sdk';
interface UserInteractions {
recentAlbums?: AlbumResponseDto[];
versions?: ServerVersionHistoryResponseDto[];
aboutInfo?: ServerAboutResponseDto;
serverInfo?: ServerStorageResponseDto;
}
const defaultUserInteraction: UserInteractions = {
recentAlbums: undefined,
versions: undefined,
aboutInfo: undefined,
serverInfo: undefined,
};
export const resetUserInteraction = () => {
Object.assign(userInteraction, defaultUserInteraction);
};
export const userInteraction = $state<UserInteractions>(defaultUserInteraction);