feat(recipe): View-Beacon beim oeffnen der Detailseite

Fire-and-forget POST /api/recipes/[id]/view in onMount, nur wenn
profileStore.active gesetzt. Schreibt last_viewed_at fuers Profil —
Voraussetzung fuer den Sort 'Zuletzt angesehen' auf der Hauptseite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-22 14:28:32 +02:00
parent 1214b9e01d
commit f495c024c6

View File

@@ -355,6 +355,17 @@
}
};
document.addEventListener('visibilitychange', onVisibility);
// Track view per active profile (fire-and-forget). Skipped when no
// profile is active — we'd just be writing rows nobody can sort against later.
if (profileStore.active) {
void fetch(`/api/recipes/${data.recipe.id}/view`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ profile_id: profileStore.active.id })
});
}
return () => document.removeEventListener('visibilitychange', onVisibility);
});