remove buffer file delete whe user change route

This commit is contained in:
smanylov
2026-03-17 11:49:57 +07:00
parent f56e6ba6d1
commit c61598010c
-24
View File
@@ -3,36 +3,12 @@
import { useEffect, useRef, useCallback } from 'react';
import { tokenLifeExtension } from '@/app/actions/auth';
import { usePathname, useSearchParams } from 'next/navigation';
import { removeUserFile } from '@/app/actions/fileEntity';
export default function ActivityTracker() {
const lastRefreshTime = useRef(Date.now());
const activityTimeoutRef = useRef<NodeJS.Timeout>(null);
const isRefreshing = useRef(false);
const pathname = usePathname();
const searchParams = useSearchParams();
useEffect(() => {
const selectedId = document.cookie
.split('; ')
.find(row => row.startsWith('searchedFileId='))
?.split('=')[1];
const handleCookie = async () => {
if (selectedId) {
await removeUserFile(selectedId, 1);
document.cookie = 'searchedFileId=; path=/; max-age=0';
}
};
if (selectedId) {
handleCookie();
}
}, [pathname, searchParams]);
// Debounce функция
const debounce = useCallback((func: () => void, delay: number) => {
if (activityTimeoutRef.current) {