Skip to content

Commit

Permalink
Merge pull request #170 from NobodyForNothing/144-still-issues-with-w…
Browse files Browse the repository at this point in the history
…ith-add-relative-timeframe

Fix newest entries missing
  • Loading branch information
derdilla authored Oct 1, 2023
2 parents 0585b3b + a8e03aa commit db07b05
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
20 changes: 14 additions & 6 deletions lib/model/ram_only_implementations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,11 @@ class RamSettings extends ChangeNotifier implements Settings {
displayDataStart = newInterval[0];
displayDataEnd = newInterval[1];
}

@override
void setToMostRecentIntervall() {
changeStepSize(graphStepSize);
}

@override
void moveDisplayDataByStep(int directionalStep) {
Expand All @@ -566,7 +571,7 @@ class RamSettings extends ChangeNotifier implements Settings {
break;
case TimeStep.lifetime:
displayDataStart = DateTime.fromMillisecondsSinceEpoch(1);
displayDataEnd = DateTime.now();
displayDataEnd = DateTime.now().copyWith(hour: 23, minute: 59, second: 59);
break;
case TimeStep.last30Days:
displayDataStart = oldStart.copyWith(day: oldStart.day + directionalStep * 30);
Expand Down Expand Up @@ -598,13 +603,16 @@ class RamSettings extends ChangeNotifier implements Settings {
return [start, start.copyWith(year: now.year + 1)];
case TimeStep.lifetime:
final start = DateTime.fromMillisecondsSinceEpoch(1);
return [start, now];
final endOfToday = now.copyWith(hour: 23, minute: 59, second: 59);
return [start, endOfToday];
case TimeStep.last7Days:
final start = now.copyWith(day: now.day-7);
return [start, now];
final start = now.copyWith(day: now.day - 7);
final endOfToday = now.copyWith(hour: 23, minute: 59, second: 59);
return [start, endOfToday];
case TimeStep.last30Days:
final start = now.copyWith(day: now.day-30);
return [start, now];
final start = now.copyWith(day: now.day - 30);
final endOfToday = now.copyWith(hour: 23, minute: 59, second: 59);
return [start, endOfToday];
case TimeStep.custom:
// fallback, TimeStep will be reset by getter
return [DateTime.fromMillisecondsSinceEpoch(-1), DateTime.fromMillisecondsSinceEpoch(-1)];
Expand Down
19 changes: 13 additions & 6 deletions lib/model/settings_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ class Settings extends ChangeNotifier {
displayDataEnd = newInterval[1];
}

void setToMostRecentIntervall() {
changeStepSize(graphStepSize);
}

void moveDisplayDataByStep(int directionalStep) {
final oldStart = displayDataStart;
final oldEnd = displayDataEnd;
Expand All @@ -161,7 +165,7 @@ class Settings extends ChangeNotifier {
break;
case TimeStep.lifetime:
displayDataStart = DateTime.fromMillisecondsSinceEpoch(1);
displayDataEnd = DateTime.now();
displayDataEnd = DateTime.now().copyWith(hour: 23, minute: 59, second: 59);
break;
case TimeStep.last30Days:
displayDataStart = oldStart.copyWith(day: oldStart.day + directionalStep * 30);
Expand Down Expand Up @@ -192,13 +196,16 @@ class Settings extends ChangeNotifier {
return [start, start.copyWith(year: now.year + 1)];
case TimeStep.lifetime:
final start = DateTime.fromMillisecondsSinceEpoch(1);
return [start, now];
final endOfToday = now.copyWith(hour: 23, minute: 59, second: 59);
return [start, endOfToday];
case TimeStep.last7Days:
final start = now.copyWith(day: now.day-7);
return [start, now];
final start = now.copyWith(day: now.day - 7);
final endOfToday = now.copyWith(hour: 23, minute: 59, second: 59);
return [start, endOfToday];
case TimeStep.last30Days:
final start = now.copyWith(day: now.day-30);
return [start, now];
final start = now.copyWith(day: now.day - 30);
final endOfToday = now.copyWith(hour: 23, minute: 59, second: 59);
return [start, endOfToday];
case TimeStep.custom:
// fallback, TimeStep will be reset by getter
return [DateTime.fromMillisecondsSinceEpoch(-1), DateTime.fromMillisecondsSinceEpoch(-1)];
Expand Down
4 changes: 4 additions & 0 deletions lib/screens/add_measurement.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ class _AddMeasurementPageState extends State<AddMeasurementPage> {
await ExportConfigurationModel.get(Provider.of<Settings>(context, listen: false), localizations));
exporter.export();
}
// ensures the most recent entry is visible when submitting a new measurement
if (settings.graphStepSize != TimeStep.custom) {
settings.setToMostRecentIntervall();
}
navigator.pop();
}
},
Expand Down

0 comments on commit db07b05

Please sign in to comment.