add warp config, update to flutter 1.22
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:combine/combine.dart';
|
||||
import 'package:dartx/dartx.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:hiddify/core/haptic/haptic_service.dart';
|
||||
import 'package:hiddify/core/localization/translations.dart';
|
||||
import 'package:hiddify/core/preferences/preferences_provider.dart';
|
||||
@@ -85,46 +85,41 @@ class ProxiesOverviewNotifier extends _$ProxiesOverviewNotifier with AppLogger {
|
||||
List<ProxyGroupEntity> proxies,
|
||||
ProxiesSort sortBy,
|
||||
) async {
|
||||
return CombineWorker().execute(
|
||||
() {
|
||||
final groupWithSelected = {
|
||||
for (final o in proxies) o.tag: o.selected,
|
||||
};
|
||||
final sortedProxies = <ProxyGroupEntity>[];
|
||||
for (final group in proxies) {
|
||||
final sortedItems = switch (sortBy) {
|
||||
ProxiesSort.name => group.items.sortedWith((a, b) {
|
||||
if (a.type.isGroup && !b.type.isGroup) return -1;
|
||||
if (!a.type.isGroup && b.type.isGroup) return 1;
|
||||
return a.tag.compareTo(b.tag);
|
||||
}),
|
||||
ProxiesSort.delay => group.items.sortedWith((a, b) {
|
||||
if (a.type.isGroup && !b.type.isGroup) return -1;
|
||||
if (!a.type.isGroup && b.type.isGroup) return 1;
|
||||
final groupWithSelected = {
|
||||
for (final o in proxies) o.tag: o.selected,
|
||||
};
|
||||
final sortedProxies = <ProxyGroupEntity>[];
|
||||
for (final group in proxies) {
|
||||
final sortedItems = switch (sortBy) {
|
||||
ProxiesSort.name => group.items.sortedWith((a, b) {
|
||||
if (a.type.isGroup && !b.type.isGroup) return -1;
|
||||
if (!a.type.isGroup && b.type.isGroup) return 1;
|
||||
return a.tag.compareTo(b.tag);
|
||||
}),
|
||||
ProxiesSort.delay => group.items.sortedWith((a, b) {
|
||||
if (a.type.isGroup && !b.type.isGroup) return -1;
|
||||
if (!a.type.isGroup && b.type.isGroup) return 1;
|
||||
|
||||
final ai = a.urlTestDelay;
|
||||
final bi = b.urlTestDelay;
|
||||
if (ai == 0 && bi == 0) return -1;
|
||||
if (ai == 0 && bi > 0) return 1;
|
||||
if (ai > 0 && bi == 0) return -1;
|
||||
return ai.compareTo(bi);
|
||||
}),
|
||||
ProxiesSort.unsorted => group.items,
|
||||
};
|
||||
final items = <ProxyItemEntity>[];
|
||||
for (final item in sortedItems) {
|
||||
if (groupWithSelected.keys.contains(item.tag)) {
|
||||
items
|
||||
.add(item.copyWith(selectedTag: groupWithSelected[item.tag]));
|
||||
} else {
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
sortedProxies.add(group.copyWith(items: items));
|
||||
final ai = a.urlTestDelay;
|
||||
final bi = b.urlTestDelay;
|
||||
if (ai == 0 && bi == 0) return -1;
|
||||
if (ai == 0 && bi > 0) return 1;
|
||||
if (ai > 0 && bi == 0) return -1;
|
||||
return ai.compareTo(bi);
|
||||
}),
|
||||
ProxiesSort.unsorted => group.items,
|
||||
};
|
||||
final items = <ProxyItemEntity>[];
|
||||
for (final item in sortedItems) {
|
||||
if (groupWithSelected.keys.contains(item.tag)) {
|
||||
items.add(item.copyWith(selectedTag: groupWithSelected[item.tag]));
|
||||
} else {
|
||||
items.add(item);
|
||||
}
|
||||
return sortedProxies;
|
||||
},
|
||||
);
|
||||
}
|
||||
sortedProxies.add(group.copyWith(items: items));
|
||||
}
|
||||
return sortedProxies;
|
||||
}
|
||||
|
||||
Future<void> changeProxy(String groupTag, String outboundTag) async {
|
||||
|
||||
Reference in New Issue
Block a user