mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-25 08:12:19 +08:00
Analytics oldestEvent: Handle cases of no events
This commit is contained in:
@ -109,6 +109,9 @@ class AnalyticsStorage {
|
||||
Future<DateTime> oldestEvent() async {
|
||||
var fileNames = (await _availableFiles()).map(p.basename);
|
||||
var timestamps = fileNames.map(int.parse);
|
||||
if (timestamps.isEmpty) {
|
||||
return DateTime.now();
|
||||
}
|
||||
var smallest = timestamps.reduce(math.min);
|
||||
|
||||
return DateTime.fromMillisecondsSinceEpoch(smallest, isUtc: true);
|
||||
|
Reference in New Issue
Block a user