From 3d3a190014608b277624f8c4f56326aa0638b4d7 Mon Sep 17 00:00:00 2001 From: Hiddify Date: Wed, 31 Jan 2024 10:02:02 +0100 Subject: [PATCH] new: make activated profile always in top --- lib/features/profile/data/profile_data_source.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/features/profile/data/profile_data_source.dart b/lib/features/profile/data/profile_data_source.dart index 9fc50e60..e6045db6 100644 --- a/lib/features/profile/data/profile_data_source.dart +++ b/lib/features/profile/data/profile_data_source.dart @@ -76,9 +76,12 @@ class ProfileDao extends DatabaseAccessor }) { return (profileEntries.select() ..orderBy( - [ + [(tbl) => OrderingTerm( + expression: tbl.active, + mode: OrderingMode.desc, + ), (tbl) { - final trafficRatio = (tbl.download + tbl.upload) / tbl.total; + final trafficRatio = (tbl.download + tbl.upload) / tbl.total; final isExpired = tbl.expire.isSmallerOrEqualValue(DateTime.now()); return OrderingTerm( @@ -90,8 +93,9 @@ class ProfileDao extends DatabaseAccessor }, switch (sort) { ProfilesSort.name => (tbl) => OrderingTerm( - expression: tbl.name, + expression: tbl.name, mode: orderMap[sortMode]!, + ), ProfilesSort.lastUpdate => (tbl) => OrderingTerm( expression: tbl.lastUpdate,