Skip to content

Commit b5e41fb

Browse files
committed
Fix fcf4671
1 parent 172d95a commit b5e41fb

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/api/color_provider.dart

-2
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,10 @@ class ColorProvider {
6868
}
6969

7070
static save() async {
71-
final stopwatch = Stopwatch()..start();
7271
await ConfigProvider.getStorage().write(
7372
key: 'lessonColors',
7473
value: jsonEncode(_lessonColors.map((key, value) => MapEntry(key, colors.indexOf(value)))),
7574
);
76-
print('${stopwatch.elapsedMilliseconds}ms');
7775
}
7876

7977
static init(String json) {

lib/api/downloader.dart

+10-2
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,19 @@ class Downloader {
305305

306306
final result = await resultFuture;
307307
final already = await alreadyFuture;
308+
int? firstWhere;
308309

309310
for (final newsArticle in result['articles']) {
310311
//Skip redownload if date is the same. Saves time
311-
if (newsArticle['date'] ==
312-
already.firstWhere((article) => article.uid == newsArticle['uid']).date) {
312+
try {
313+
firstWhere = already
314+
.firstWhere((article) => article.uid == newsArticle['uid'])
315+
.date
316+
.millisecondsSinceEpoch;
317+
} catch (_) {
318+
firstWhere = null;
319+
}
320+
if (newsArticle['date'] != firstWhere) {
313321
print('Adding article ${newsArticle['titre']}');
314322
Client.getClient().addRequest(Action.getArticleDetails, (articleDetails) async {
315323
await db.insert(

0 commit comments

Comments
 (0)