new: update active profile and its ping,

This commit is contained in:
Hiddify
2024-02-13 03:55:28 +01:00
parent 467a757de2
commit 07e345c7d2
3 changed files with 24 additions and 5 deletions

View File

@@ -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),
),

View File

@@ -26,7 +26,25 @@ Stream<ProxyItemEntity?> activeProxyGroup(ActiveProxyGroupRef ref) async* {
.watch(proxyRepositoryProvider)
.watchActiveProxies()
.map((event) => event.getOrElse((l) => throw l))
.map((event) => event.firstOrNull?.items.firstOrNull);
.map((event) {
final Map<String, ProxyGroupEntity> itemMap =
event.fold({}, (Map<String, ProxyGroupEntity> 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