Skip to content

Commit 51c7b69

Browse files
Khader-1gnprice
authored andcommitted
subscription_list: Fix stream name sorting case insensitively
Stream names should be sorted regardless of the case and this applies for pinned and unpinned subscriptions: **A comes before b and B comes after a** So this adds simple toLowerCase transformation before sorting Fixes: #568
1 parent 1560337 commit 51c7b69

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/widgets/subscription_list.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class _SubscriptionListPageState extends State<SubscriptionListPage> with PerAcc
7777
}
7878
}
7979
// TODO(i18n): add locale-aware sorting
80-
pinned.sortBy((subscription) => subscription.name);
81-
unpinned.sortBy((subscription) => subscription.name);
80+
pinned.sortBy((subscription) => subscription.name.toLowerCase());
81+
unpinned.sortBy((subscription) => subscription.name.toLowerCase());
8282

8383
return Scaffold(
8484
appBar: AppBar(title: const Text("Streams")),

test/widgets/subscription_list_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@ void main() {
120120
]);
121121
check(listedStreamIds(tester)).deepEquals([2, 3, 1]);
122122
});
123+
124+
testWidgets('subscriptions sorting is case insensitive', (tester) async {
125+
await setupStreamListPage(tester, subscriptions: [
126+
eg.subscription(eg.stream(streamId: 1, name: 'a'), pinToTop: true),
127+
eg.subscription(eg.stream(streamId: 2, name: 'B'), pinToTop: true),
128+
eg.subscription(eg.stream(streamId: 3, name: 'c'), pinToTop: true),
129+
eg.subscription(eg.stream(streamId: 4, name: 'D'), pinToTop: false),
130+
eg.subscription(eg.stream(streamId: 5, name: 'e'), pinToTop: false),
131+
eg.subscription(eg.stream(streamId: 6, name: 'F'), pinToTop: false),
132+
]);
133+
check(listedStreamIds(tester)).deepEquals([1, 2, 3, 4, 5, 6]);
134+
});
123135
});
124136

125137
testWidgets('unread badge shows with unreads', (tester) async {

0 commit comments

Comments
 (0)