Отслеживание просмотров задач: task_views, POST /api/tasks/:id/view и обновление /api/home/recent
This commit is contained in:
@@ -3101,6 +3101,24 @@ const TaskDetail = () => {
|
||||
}
|
||||
}, [taskError, setLocation]);
|
||||
|
||||
// Record that the user viewed this task so it appears in Home → "Recent".
|
||||
useEffect(() => {
|
||||
if (!taskIdNumber || !currentUser) return;
|
||||
let cancelled = false;
|
||||
apiRequest('POST', `/api/tasks/${taskIdNumber}/view`)
|
||||
.then(() => {
|
||||
if (!cancelled) {
|
||||
queryClient.invalidateQueries({ queryKey: ['home'] });
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('[TaskDetail] Failed to record task view:', err);
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [taskIdNumber, currentUser?.id]);
|
||||
|
||||
// На мобильном разворачиваем первую пользовательскую вкладку по умолчанию;
|
||||
// если вкладок нет — разворачиваем fallback-секцию «Задача» с полями
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user