refactor(FilterManager): replace API call with listCommunities utility for community data retrieval
Publish Docker image / build-and-push (push) Successful in 2m7s
Publish Docker image / build-and-push (push) Successful in 2m7s
- Updated the community data fetching logic in FilterManager to utilize the listCommunities function, improving code clarity and maintainability. - Ensured proper handling of aborted requests to prevent unnecessary state updates. Made-with: Cursor
This commit is contained in:
@@ -47,6 +47,7 @@ import {
|
|||||||
import { CSS } from '@dnd-kit/utilities';
|
import { CSS } from '@dnd-kit/utilities';
|
||||||
import { normalizeGateways, countryToFlag } from './utils/serverUtils.js';
|
import { normalizeGateways, countryToFlag } from './utils/serverUtils.js';
|
||||||
import { usePing } from './contexts/PingContext.jsx';
|
import { usePing } from './contexts/PingContext.jsx';
|
||||||
|
import { listCommunities } from './lib/evobgpData.js';
|
||||||
|
|
||||||
// Компонент автокомплита для выбора Community
|
// Компонент автокомплита для выбора Community
|
||||||
function CommunityAutocomplete({ label, value, onChange, communities = [], required = false, placeholder = 'Введите или выберите community...', baseAS = '65001' }) {
|
function CommunityAutocomplete({ label, value, onChange, communities = [], required = false, placeholder = 'Введите или выберите community...', baseAS = '65001' }) {
|
||||||
@@ -911,10 +912,11 @@ function FilterManager() {
|
|||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const res = await api.get(`/communities`, opts);
|
const rows = await listCommunities();
|
||||||
setCommunities(Array.isArray(res.data) ? res.data : []);
|
if (signal.aborted) return;
|
||||||
|
setCommunities(Array.isArray(rows) ? rows : []);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e?.name === 'CanceledError' || e?.name === 'AbortError' || e?.code === 'ERR_CANCELED') return;
|
if (signal.aborted) return;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user