Refactor Mihomo proxy groups component to improve loading state management
Publish telemt-api gateway Docker image / test (push) Successful in 27s
Publish telemt-api gateway Docker image / build-and-push (push) Successful in 2m23s

- Introduced `untrack` from Svelte to prevent infinite rendering loops during loading state changes.
- Enhanced loading state handling by ensuring that loading notifications are managed correctly without causing UI flickering.
- Improved overall data fetching logic for better user experience during proxy updates.
This commit is contained in:
Denozordec
2026-03-31 17:50:54 +07:00
parent 2fd98f8c3d
commit 56832e525d
@@ -1,4 +1,5 @@
<script lang="ts">
import { untrack } from 'svelte';
import { ApiError, fetchMihomoJson, mihomoPut } from '$lib/api/client.js';
import type { MihomoProxiesResponse, MihomoProxyEntry } from '$lib/api/mihomo-types.js';
import { Button } from '$lib/components/ui/button/index.js';
@@ -45,8 +46,10 @@
async function loadProxies() {
const a = alias;
if (!a) return;
const notify = onLoadingChange;
proxiesLoading = true;
onLoadingChange?.(true);
// Иначе $effect подпишется на проп-колбэк: новая fn каждый рендер родителя → бесконечный цикл /proxies
untrack(() => notify?.(true));
proxiesErr = null;
try {
proxiesData = await fetchMihomoJson<MihomoProxiesResponse>(a, 'proxies');
@@ -55,7 +58,7 @@
// не затираем успешный снимок при сбое обновления — без мерцания UI
} finally {
proxiesLoading = false;
onLoadingChange?.(false);
untrack(() => notify?.(false));
}
}