refactor(frontend): utility dedup, component splits, dead code removal (#193–#200) #241
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { m } from '$lib/paraglide/messages.js';
|
||||
import DocumentTopBar from '$lib/components/DocumentTopBar.svelte';
|
||||
import DocumentViewer from '$lib/components/DocumentViewer.svelte';
|
||||
@@ -31,6 +31,7 @@ $effect(() => {
|
||||
async function loadFile(id: string) {
|
||||
isLoading = true;
|
||||
fileError = '';
|
||||
if (fileUrl) URL.revokeObjectURL(fileUrl);
|
||||
fileUrl = '';
|
||||
|
||||
try {
|
||||
@@ -51,6 +52,10 @@ async function loadFile(id: string) {
|
||||
}
|
||||
}
|
||||
|
||||
onDestroy(() => {
|
||||
if (fileUrl) URL.revokeObjectURL(fileUrl);
|
||||
});
|
||||
|
||||
// ── Mode state ───────────────────────────────────────────────────────────────
|
||||
|
||||
let transcribeMode = $state(false);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { enhance } from '$app/forms';
|
||||
import { onMount, untrack } from 'svelte';
|
||||
import { onMount, onDestroy, untrack } from 'svelte';
|
||||
import { m } from '$lib/paraglide/messages.js';
|
||||
import DocumentViewer from '$lib/components/DocumentViewer.svelte';
|
||||
import WhoWhenSection from '$lib/components/document/WhoWhenSection.svelte';
|
||||
@@ -34,6 +34,7 @@ $effect(() => {
|
||||
async function loadFile(id: string) {
|
||||
isLoading = true;
|
||||
fileError = '';
|
||||
if (fileUrl) URL.revokeObjectURL(fileUrl);
|
||||
fileUrl = '';
|
||||
try {
|
||||
const response = await fetch(`/api/documents/${id}/file`);
|
||||
@@ -47,6 +48,10 @@ async function loadFile(id: string) {
|
||||
}
|
||||
}
|
||||
|
||||
onDestroy(() => {
|
||||
if (fileUrl) URL.revokeObjectURL(fileUrl);
|
||||
});
|
||||
|
||||
// Form state
|
||||
let tags = $state(untrack(() => doc.tags?.map((t: { name: string }) => t.name) ?? []));
|
||||
let senderId = $state(untrack(() => doc.sender?.id ?? ''));
|
||||
|
||||
Reference in New Issue
Block a user