Отслеживание просмотров задач: task_views, POST /api/tasks/:id/view и обновление /api/home/recent

This commit is contained in:
2026-08-24 15:40:30 +03:00
parent 74abd8fad5
commit a4eaf65915
7 changed files with 107 additions and 1 deletions

View File

@@ -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(() => {