fix stale stuff?
ci / docker_image (push) Successful in 2m7s
ci / deploy (push) Successful in 25s

This commit is contained in:
2026-04-11 23:40:23 -05:00
parent bce9a19776
commit 264b44f555
2 changed files with 44 additions and 37 deletions
+19 -12
View File
@@ -25,12 +25,19 @@
export let inquireCallback: (item: Item) => void;
export let claimCallback: (item: Item) => void;
let timeSincePosted: number | string = (new Date().getTime() - item.foundDate.getTime()) / 1000 / 60 / 60 / 24; // days
// if (timeSincePosted < 1) {
// timeSincePosted = '<1';
// } else {
// timeSincePosted = Math.round(timeSincePosted);
// }
// Normalize the foundDate in case it was serialized (string) in prod builds
// (SSR/JSON serialization often turns Date objects into strings).
const foundDateObj: Date = item?.foundDate instanceof Date
? item.foundDate
: new Date(item?.foundDate);
// Compute days since posted as a number (always a number, fall back to 0 on invalid date)
let timeSincePosted: number = (() => {
const t = foundDateObj?.getTime?.();
if (!t || Number.isNaN(t)) return 0;
return (Date.now() - t) / 1000 / 60 / 60 / 24; // days (float)
})();
// If you want to round/display differently you can do that in the template.
</script>
@@ -59,13 +66,13 @@
<Tooltip.Trigger
>
<Badge variant="outline"
class="inline-block {user?.settings !== null && user?.settings !== undefined && timeSincePosted >= user.settings.staleItemDays ? 'text-warning' : ''}">{timeSincePosted < 1 ? "<1" : Math.round(timeSincePosted)}
class="inline-block {user?.settings?.staleItemDays !== undefined && timeSincePosted >= user.settings.staleItemDays ? 'text-warning' : ''}">{timeSincePosted < 1 ? "<1" : Math.round(timeSincePosted)}
day{(timeSincePosted <= 1) ? '' : 's'} ago
</Badge>
</Tooltip.Trigger
>
<Tooltip.Content>
<p>{item.foundDate.toLocaleDateString('en-US', dateFormatOptions)}</p>
<p>{foundDateObj.toLocaleDateString('en-US', dateFormatOptions)}</p>
</Tooltip.Content>
</Tooltip.Root>
</Tooltip.Provider>
@@ -96,13 +103,13 @@
<Button variant="ghost" class="text-positive"
onclick={async () => {await approveDenyItem({id: item.id, approved: true});
invalidateAll()}}>
await invalidateAll()}}>
<CheckIcon />
Approve
</Button>
<Button variant="ghost" class="text-destructive"
onclick={async () => {await approveDenyItem({id: item.id, approved: false});
invalidateAll()}}>
await invalidateAll()}}>
<XIcon />
Deny
</Button>
@@ -116,13 +123,13 @@
{:else}
<Button variant="ghost" class="text-destructive"
onclick={async () => {await approveDenyItem({id: item.id, approved: false});
invalidateAll()}}>
await invalidateAll()}}>
<TrashIcon />
Delete
</Button>
<Button variant="ghost" class="text-action"
onclick={async () => {await restoreClaimedItem(item.id);
invalidateAll()}}>
await invalidateAll()}}>
<ArchiveRestoreIcon />
Restore
</Button>