@@ -1,8 +1,5 @@
|
||||
import { defaultLang, langs } from '$lib/constants';
|
||||
import { lang } from '$lib/stores/preferences.store';
|
||||
import { initApp } from '$lib/utils';
|
||||
import { defaults } from '@immich/sdk';
|
||||
import { init, register } from 'svelte-i18n';
|
||||
import { get } from 'svelte/store';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const ssr = false;
|
||||
@@ -14,13 +11,7 @@ export const load = (async ({ fetch }) => {
|
||||
// https://github.com/oazapfts/oazapfts/blob/main/README.md#fetch-options
|
||||
defaults.fetch = fetch;
|
||||
|
||||
for (const { code, loader } of langs) {
|
||||
register(code, loader);
|
||||
}
|
||||
|
||||
const preferenceLang = get(lang);
|
||||
|
||||
await init({ fallbackLocale: preferenceLang === 'dev' ? 'dev' : defaultLang.code, initialLocale: preferenceLang });
|
||||
await initApp();
|
||||
|
||||
return {
|
||||
meta: {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { AppRoute } from '$lib/constants';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load = (({ url }) => {
|
||||
enum LinkTarget {
|
||||
HOME = 'home',
|
||||
UNSUBSCRIBE = 'unsubscribe',
|
||||
VIEW_ASSET = 'view_asset',
|
||||
}
|
||||
|
||||
const queryParams = url.searchParams;
|
||||
const target = queryParams.get('target') as LinkTarget;
|
||||
|
||||
switch (target) {
|
||||
case LinkTarget.HOME: {
|
||||
return redirect(302, AppRoute.PHOTOS);
|
||||
}
|
||||
|
||||
case LinkTarget.UNSUBSCRIBE: {
|
||||
return redirect(302, `${AppRoute.USER_SETTINGS}?isOpen=notifications`);
|
||||
}
|
||||
|
||||
case LinkTarget.VIEW_ASSET: {
|
||||
const id = queryParams.get('id');
|
||||
if (id) {
|
||||
return redirect(302, `${AppRoute.PHOTOS}/${id}`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return redirect(302, AppRoute.PHOTOS);
|
||||
}) satisfies PageLoad;
|
||||
Reference in New Issue
Block a user