refactor(briefwechsel): ThumbnailRow captures now at prop binding
Defaults `now` in $props() destructure so each row instance freezes its reference time at mount, instead of calling new Date() inside the $derived every reactivity tick. No behavioural change — the date math is stable across re-renders for a given row — but drops the nullish-coalesce dance and is cleaner under Storybook-style testing where a deterministic `now` is injected. Refs #305 Fixes @felixbrandt suggestion 3 from PR review Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -27,7 +27,7 @@ let {
|
|||||||
doc,
|
doc,
|
||||||
isOut,
|
isOut,
|
||||||
showOtherParty,
|
showOtherParty,
|
||||||
now
|
now = new Date()
|
||||||
}: {
|
}: {
|
||||||
doc: Doc;
|
doc: Doc;
|
||||||
isOut: boolean;
|
isOut: boolean;
|
||||||
@@ -46,9 +46,7 @@ const otherPartyName = $derived(
|
|||||||
: ''
|
: ''
|
||||||
);
|
);
|
||||||
const relativeYearLabel = $derived(
|
const relativeYearLabel = $derived(
|
||||||
doc.documentDate
|
doc.documentDate ? relativeYearsDe(new Date(doc.documentDate + 'T12:00:00'), now) : ''
|
||||||
? relativeYearsDe(new Date(doc.documentDate + 'T12:00:00'), now ?? new Date())
|
|
||||||
: ''
|
|
||||||
);
|
);
|
||||||
const directionLabel = $derived(isOut ? 'Gesendet' : 'Empfangen');
|
const directionLabel = $derived(isOut ? 'Gesendet' : 'Empfangen');
|
||||||
const ariaLabel = $derived(
|
const ariaLabel = $derived(
|
||||||
|
|||||||
Reference in New Issue
Block a user