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:
@@ -355,6 +355,17 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
document.addEventListener('visibilitychange', onVisibility);
|
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);
|
return () => document.removeEventListener('visibilitychange', onVisibility);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user