fix(briefwechsel): repair 500 by consuming backend thumbnailUrl directly
ConversationThumbnail still imported the `$lib/thumbnails` helper that
a02f6cdc deleted, so every SSR render of /briefwechsel crashed with
"Cannot find module '$lib/thumbnails'". Finish that refactor by reading
`doc.thumbnailUrl` straight off the Document DTO (same shape
DocumentThumbnail already uses), and update the spec fixtures to match.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { thumbnailUrl } from '$lib/thumbnails';
|
import type { components } from '$lib/generated/api';
|
||||||
|
|
||||||
type Doc = {
|
type Doc = Pick<
|
||||||
id: string;
|
components['schemas']['Document'],
|
||||||
thumbnailKey?: string;
|
'id' | 'thumbnailUrl' | 'thumbnailAspect' | 'pageCount'
|
||||||
thumbnailGeneratedAt?: string;
|
>;
|
||||||
thumbnailAspect?: 'PORTRAIT' | 'LANDSCAPE';
|
|
||||||
pageCount?: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
let { doc }: { doc: Doc } = $props();
|
let { doc }: { doc: Doc } = $props();
|
||||||
|
|
||||||
const url = $derived(thumbnailUrl(doc));
|
const url = $derived(doc.thumbnailUrl ?? null);
|
||||||
const aspect = $derived(doc.thumbnailAspect ?? 'PORTRAIT');
|
const aspect = $derived(doc.thumbnailAspect ?? 'PORTRAIT');
|
||||||
const pageCount = $derived(doc.pageCount ?? 1);
|
const pageCount = $derived(doc.pageCount ?? 1);
|
||||||
const tileClass = $derived(aspect === 'LANDSCAPE' ? 'h-[120px] w-[168px]' : 'h-[168px] w-[120px]');
|
const tileClass = $derived(aspect === 'LANDSCAPE' ? 'h-[120px] w-[168px]' : 'h-[168px] w-[120px]');
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ describe('ConversationThumbnail', () => {
|
|||||||
render(ConversationThumbnail, {
|
render(ConversationThumbnail, {
|
||||||
doc: {
|
doc: {
|
||||||
id: '1111',
|
id: '1111',
|
||||||
thumbnailKey: 'thumbnails/1111.jpg',
|
thumbnailUrl: '/api/documents/1111/thumbnail?v=2026-04-10T09%3A00%3A00Z',
|
||||||
thumbnailGeneratedAt: '2026-04-10T09:00:00Z',
|
|
||||||
thumbnailAspect: 'PORTRAIT',
|
thumbnailAspect: 'PORTRAIT',
|
||||||
pageCount: 1
|
pageCount: 1
|
||||||
}
|
}
|
||||||
@@ -29,7 +28,7 @@ describe('ConversationThumbnail', () => {
|
|||||||
render(ConversationThumbnail, {
|
render(ConversationThumbnail, {
|
||||||
doc: {
|
doc: {
|
||||||
id: 'p1',
|
id: 'p1',
|
||||||
thumbnailKey: 'thumbnails/p1.jpg',
|
thumbnailUrl: '/api/documents/p1/thumbnail?v=2026-04-10T09%3A00%3A00Z',
|
||||||
thumbnailAspect: 'PORTRAIT',
|
thumbnailAspect: 'PORTRAIT',
|
||||||
pageCount: 1
|
pageCount: 1
|
||||||
}
|
}
|
||||||
@@ -43,7 +42,7 @@ describe('ConversationThumbnail', () => {
|
|||||||
render(ConversationThumbnail, {
|
render(ConversationThumbnail, {
|
||||||
doc: {
|
doc: {
|
||||||
id: 'l1',
|
id: 'l1',
|
||||||
thumbnailKey: 'thumbnails/l1.jpg',
|
thumbnailUrl: '/api/documents/l1/thumbnail?v=2026-04-10T09%3A00%3A00Z',
|
||||||
thumbnailAspect: 'LANDSCAPE',
|
thumbnailAspect: 'LANDSCAPE',
|
||||||
pageCount: 1
|
pageCount: 1
|
||||||
}
|
}
|
||||||
@@ -57,7 +56,7 @@ describe('ConversationThumbnail', () => {
|
|||||||
render(ConversationThumbnail, {
|
render(ConversationThumbnail, {
|
||||||
doc: {
|
doc: {
|
||||||
id: 'n1',
|
id: 'n1',
|
||||||
thumbnailKey: 'thumbnails/n1.jpg'
|
thumbnailUrl: '/api/documents/n1/thumbnail?v=2026-04-10T09%3A00%3A00Z'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -69,7 +68,7 @@ describe('ConversationThumbnail', () => {
|
|||||||
render(ConversationThumbnail, {
|
render(ConversationThumbnail, {
|
||||||
doc: {
|
doc: {
|
||||||
id: 'm1',
|
id: 'm1',
|
||||||
thumbnailKey: 'thumbnails/m1.jpg',
|
thumbnailUrl: '/api/documents/m1/thumbnail?v=2026-04-10T09%3A00%3A00Z',
|
||||||
thumbnailAspect: 'PORTRAIT',
|
thumbnailAspect: 'PORTRAIT',
|
||||||
pageCount: 4
|
pageCount: 4
|
||||||
}
|
}
|
||||||
@@ -87,7 +86,7 @@ describe('ConversationThumbnail', () => {
|
|||||||
render(ConversationThumbnail, {
|
render(ConversationThumbnail, {
|
||||||
doc: {
|
doc: {
|
||||||
id: 's1',
|
id: 's1',
|
||||||
thumbnailKey: 'thumbnails/s1.jpg',
|
thumbnailUrl: '/api/documents/s1/thumbnail?v=2026-04-10T09%3A00%3A00Z',
|
||||||
thumbnailAspect: 'PORTRAIT',
|
thumbnailAspect: 'PORTRAIT',
|
||||||
pageCount: 1
|
pageCount: 1
|
||||||
}
|
}
|
||||||
@@ -97,7 +96,7 @@ describe('ConversationThumbnail', () => {
|
|||||||
expect(badge).toBeNull();
|
expect(badge).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders a skeleton placeholder when no thumbnailKey is set yet', () => {
|
it('renders a skeleton placeholder when no thumbnailUrl is set yet', () => {
|
||||||
render(ConversationThumbnail, {
|
render(ConversationThumbnail, {
|
||||||
doc: {
|
doc: {
|
||||||
id: 'blank',
|
id: 'blank',
|
||||||
|
|||||||
Reference in New Issue
Block a user