From 07e345c7d20d59ba25857f6047d5167dcfbc666a Mon Sep 17 00:00:00 2001 From: Hiddify Date: Tue, 13 Feb 2024 03:55:28 +0100 Subject: [PATCH] new: update active profile and its ping, --- assets/translations/strings_fa.i18n.json | 4 ++-- .../active/active_proxy_delay_indicator.dart | 5 +++-- .../proxy/active/active_proxy_notifier.dart | 20 ++++++++++++++++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/assets/translations/strings_fa.i18n.json b/assets/translations/strings_fa.i18n.json index 514c1a5a..1b6876ce 100644 --- a/assets/translations/strings_fa.i18n.json +++ b/assets/translations/strings_fa.i18n.json @@ -13,8 +13,8 @@ "sortBy": "مرتب‌سازی براساس", "addToClipboard": "به کلیپ بورد اضافه کنید", "notSet": "تنظیم نشده", - "agree": "موافق", - "decline": "کاهش می یابد", + "agree": "موافقم", + "decline": "رد", "unknown": "ناشناخته" }, "intro": { diff --git a/lib/features/proxy/active/active_proxy_delay_indicator.dart b/lib/features/proxy/active/active_proxy_delay_indicator.dart index 66d4ec9d..e1cd3f2b 100644 --- a/lib/features/proxy/active/active_proxy_delay_indicator.dart +++ b/lib/features/proxy/active/active_proxy_delay_indicator.dart @@ -26,7 +26,8 @@ class ActiveProxyDelayIndicator extends HookConsumerWidget { onTap: () async { await ref .read(activeProxyNotifierProvider.notifier) - .urlTest(value.proxy.tag); + // .urlTest(value.proxy.tag); + .urlTest("auto"); }, borderRadius: BorderRadius.circular(24), child: Padding( @@ -42,7 +43,7 @@ class ActiveProxyDelayIndicator extends HookConsumerWidget { TextSpan( children: [ TextSpan( - text: delay.toString(), + text: delay > 65000 ? "×" : delay.toString(), style: theme.textTheme.titleMedium ?.copyWith(fontWeight: FontWeight.bold), ), diff --git a/lib/features/proxy/active/active_proxy_notifier.dart b/lib/features/proxy/active/active_proxy_notifier.dart index 4dd32eee..6cd06a97 100644 --- a/lib/features/proxy/active/active_proxy_notifier.dart +++ b/lib/features/proxy/active/active_proxy_notifier.dart @@ -26,7 +26,25 @@ Stream activeProxyGroup(ActiveProxyGroupRef ref) async* { .watch(proxyRepositoryProvider) .watchActiveProxies() .map((event) => event.getOrElse((l) => throw l)) - .map((event) => event.firstOrNull?.items.firstOrNull); + .map((event) { + final Map itemMap = + event.fold({}, (Map map, item) { + map[item.tag] = item; + return map; + }); + + // Start from the item with the tag "Select" + var current = itemMap["select"]; + ProxyItemEntity? selected; + + // Traverse through the map based on the selected tag until reaching the end + while (current != null) { + selected = current.items.firstOrNull; + current = itemMap[selected?.tag]; + } + + return selected; + }); } @riverpod