feat: Добавить инициализацию загрузки данных в менеджеры ASNs, Domains и IPRanges, улучшить обработку поиска с использованием таймера
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m43s

This commit is contained in:
2025-08-27 15:16:11 +07:00
parent 298fb7c6f0
commit 82fb2404a2
3 changed files with 9 additions and 12 deletions
+3 -4
View File
@@ -40,6 +40,7 @@ function ASNsNewManager() {
const [success, setSuccess] = useState('');
const [searchTerm, setSearchTerm] = useState('');
const searchTimer = useRef(null);
const didInit = useRef(false);
const [editingAsn, setEditingAsn] = useState(null);
const [editingValue, setEditingValue] = useState('');
const [loading, setLoading] = useState(false);
@@ -95,7 +96,6 @@ function ASNsNewManager() {
};
acquire();
const interval = setInterval(acquire, 60_000);
fetchItems();
// Load WS URL once
(async () => {
try { const r = await api.get('/ws/url'); setWsUrl(String(r.data?.url || '')); } catch {}
@@ -131,10 +131,9 @@ function ASNsNewManager() {
};
useEffect(() => {
if (!didInit.current) { didInit.current = true; fetchItems(); return; }
if (searchTimer.current) clearTimeout(searchTimer.current);
searchTimer.current = setTimeout(() => {
fetchItems();
}, 350);
searchTimer.current = setTimeout(() => { fetchItems(); }, 350);
return () => { if (searchTimer.current) clearTimeout(searchTimer.current); };
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentPage, searchTerm, filterCommunity]);
+3 -4
View File
@@ -40,6 +40,7 @@ function DomainsNewManager() {
const [success, setSuccess] = useState('');
const [searchTerm, setSearchTerm] = useState('');
const searchTimer = useRef(null);
const didInit = useRef(false);
const [editingDomain, setEditingDomain] = useState(null);
const [editingValue, setEditingValue] = useState('');
const [loading, setLoading] = useState(false);
@@ -100,7 +101,6 @@ function DomainsNewManager() {
};
acquire();
const interval = setInterval(acquire, 60_000);
fetchItems();
(async () => { try { const r = await api.get('/ws/url'); setWsUrl(String(r.data?.url || '')); } catch {} })();
return () => {
clearInterval(interval);
@@ -133,10 +133,9 @@ function DomainsNewManager() {
// Подгрузка при изменении страницы/поиска/фильтра
useEffect(() => {
if (!didInit.current) { didInit.current = true; fetchItems(); return; }
if (searchTimer.current) clearTimeout(searchTimer.current);
searchTimer.current = setTimeout(() => {
fetchItems();
}, 350);
searchTimer.current = setTimeout(() => { fetchItems(); }, 350);
return () => { if (searchTimer.current) clearTimeout(searchTimer.current); };
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentPage, searchTerm, filterCommunity]);
+3 -4
View File
@@ -40,6 +40,7 @@ function IPRangesManager() {
const [success, setSuccess] = useState('');
const [searchTerm, setSearchTerm] = useState('');
const searchTimer = useRef(null);
const didInit = useRef(false);
const [editingIp, setEditingIp] = useState(null);
const [editingValue, setEditingValue] = useState('');
const [loading, setLoading] = useState(false);
@@ -111,7 +112,6 @@ function IPRangesManager() {
};
acquire();
const interval = setInterval(acquire, 60_000);
fetchItems();
(async () => { try { const r = await api.get('/ws/url'); setWsUrl(String(r.data?.url || '')); } catch {} })();
return () => {
clearInterval(interval);
@@ -143,10 +143,9 @@ function IPRangesManager() {
};
useEffect(() => {
if (!didInit.current) { didInit.current = true; fetchItems(); return; }
if (searchTimer.current) clearTimeout(searchTimer.current);
searchTimer.current = setTimeout(() => {
fetchItems();
}, 350);
searchTimer.current = setTimeout(() => { fetchItems(); }, 350);
return () => { if (searchTimer.current) clearTimeout(searchTimer.current); };
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentPage, searchTerm, filterCommunity]);