Commit 232f2e4

derdilla <82763757+NobodyForNothing@users.noreply.github.com>
2024-06-25 10:05:32
fix list ordering
Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com>
1 parent a5bafc7
Changed files (5)
app
lib
components
screens
subsettings
test
app/lib/components/dialoges/add_measurement_dialoge.dart
@@ -150,7 +150,6 @@ class _AddEntryDialogeState extends State<AddEntryDialoge> {
         || noteFocusNode.hasFocus && (notes?.isEmpty ?? true)
     ) {
       FocusScope.of(context).previousFocus();
-      print('backfocus');
     }
     return false;
   }
@@ -175,7 +174,6 @@ class _AddEntryDialogeState extends State<AddEntryDialoge> {
       onChanged: (String value) {
         if (value.isNotEmpty
             && (int.tryParse(value) ?? -1) > 40) {
-          print('object');
           FocusScope.of(context).nextFocus();
         }
       },
app/lib/components/measurement_list/measurement_list.dart
@@ -33,7 +33,7 @@ class MeasurementList extends StatelessWidget {
   Widget build(BuildContext context) {
     final localizations = AppLocalizations.of(context)!;
     final entries = FullEntryList.merged(records, notes, intakes);
-    entries.sort((a, b) => a.time.compareTo(b.time)); // FIXme everywhere else
+    entries.sort((a, b) => b.time.compareTo(a.time)); // newest first
     return Column(
       mainAxisSize: MainAxisSize.min,
       children: [
app/lib/screens/subsettings/export_import/export_button_bar.dart
@@ -168,7 +168,7 @@ void performExport(BuildContext context, [AppLocalizations? localizations]) asyn
   }
 }
 
-/// Get the records that should be exported.
+/// Get the records that should be exported (oldest first).
 Future<List<FullEntry>> _getEntries(BuildContext context) async {
   final range = Provider.of<IntervallStoreManager>(context, listen: false).exportPage.currentRange;
   final bpRepo = RepositoryProvider.of<BloodPressureRepository>(context);
app/test/ui/components/measurement_list/measurement_list_test.dart
@@ -27,14 +27,14 @@ void main() {
     expect(find.text('2022'), findsOneWidget);
     expect(find.text('2023'), findsOneWidget);
   });
-  testWidgets('entries are ordered in chronological order', (tester) async {
+  testWidgets('entries are ordered in reversed chronological order', (tester) async {
     await tester.pumpWidget(materialApp(
       MeasurementList(
         settings: Settings(),
         records: [
           mockRecord(time: DateTime.fromMillisecondsSinceEpoch(2000), sys: 2),
-          mockRecord(time: DateTime.fromMillisecondsSinceEpoch(1000), sys: 1),
-          mockRecord(time: DateTime.fromMillisecondsSinceEpoch(4000), sys: 3),
+          mockRecord(time: DateTime.fromMillisecondsSinceEpoch(4000), sys: 1),
+          mockRecord(time: DateTime.fromMillisecondsSinceEpoch(1000), sys: 3),
         ],
         notes: [],
         intakes: [],
app/test/ui/components/add_measurement_dialoge_test.dart
@@ -14,10 +14,9 @@ import 'util.dart';
 void main() {
   group('AddEntryDialoge', () {
     testWidgets('should show everything on initial page', (tester) async {
-      final repo = medRepo();
       await tester.pumpWidget(materialApp(
         AddEntryDialoge(
-          medRepo: repo,
+          availableMeds: [],
           settings: Settings(),
         ),
       ),);
@@ -38,7 +37,7 @@ void main() {
           initialRecord: mockEntryPos(
             DateTime.now(), 123, 56, 43, 'Test note', Colors.teal,
           ),
-          medRepo: medRepo(),
+          availableMeds: [],
         ),
       ),);
       await tester.pumpAndSettle();
@@ -56,7 +55,7 @@ void main() {
       await tester.pumpWidget(materialApp(
         AddEntryDialoge(
           settings: Settings(),
-          medRepo: medRepo([mockMedicine(designation: 'testmed')]),
+          availableMeds: [ mockMedicine(designation: 'testmed') ],
         ),
       ),);
       await tester.pumpAndSettle();
@@ -75,7 +74,7 @@ void main() {
       await tester.pumpWidget(materialApp(
         AddEntryDialoge(
           settings: Settings(),
-          medRepo: medRepo([mockMedicine(designation: 'testmed')]),
+          availableMeds: [ mockMedicine(designation: 'testmed') ],
         ),
       ),);
       await tester.pumpAndSettle();
@@ -105,7 +104,7 @@ void main() {
       await tester.pumpWidget(materialApp(
         AddEntryDialoge(
           settings: Settings(),
-          medRepo: medRepo([mockMedicine(designation: 'testmed', defaultDosis: 3.1415)]),
+          availableMeds: [ mockMedicine(designation: 'testmed', defaultDosis: 3.1415) ],
         ),
       ),);
       await tester.pumpAndSettle();
@@ -122,7 +121,7 @@ void main() {
       await tester.pumpWidget(materialApp(
         AddEntryDialoge(
           settings: Settings(),
-          medRepo: medRepo([mockMedicine(designation: 'testmed', defaultDosis: 3.1415)]),
+          availableMeds: [ mockMedicine(designation: 'testmed', defaultDosis: 3.1415) ],
         ),
       ),);
       await tester.pumpAndSettle();