This commit is contained in:
Lyz Coote
2026-02-02 18:41:13 +01:00
commit d6a5cb8a67
161 changed files with 8630 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { GetImageViewerData, GetStartupFile, ReadEML } from '$lib/wailsjs/go/main/App';
import DOMPurify from 'dompurify';
export const load: PageLoad = async () => {
try {
// Check if we are in viewer mode
const viewerData = await GetImageViewerData();
if (viewerData && viewerData.data) {
throw redirect(302, "/image-viewer");
}
// Check if opened with a file
const startupFile = await GetStartupFile();
if (startupFile) {
const emlContent = await ReadEML(startupFile);
if (emlContent) {
emlContent.body = DOMPurify.sanitize(emlContent.body || "");
return { email: emlContent };
}
}
} catch (e) {
// If it's a redirect, re-throw it so SvelteKit handles it
if ((e as any)?.status === 302 || (e as any)?.status === 307 || (e as any)?.status === 303 || (e as any)?.location) {
throw e;
}
console.error("Error in load function:", e);
}
return { email: null };
};