From f01ab2f6485f54ddeb41d96463efd164686344fd Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Mon, 6 Jun 2022 18:05:34 +0800 Subject: [PATCH] Get rid of useless hack --- app/lib/entity/file/file_cache_manager.dart | 8 +++----- app/lib/use_case/cache_favorite.dart | 9 ++++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/lib/entity/file/file_cache_manager.dart b/app/lib/entity/file/file_cache_manager.dart index bb14c99b..8a8b14d2 100644 --- a/app/lib/entity/file/file_cache_manager.dart +++ b/app/lib/entity/file/file_cache_manager.dart @@ -8,7 +8,6 @@ import 'package:nc_photos/entity/file.dart'; import 'package:nc_photos/entity/file/data_source.dart'; import 'package:nc_photos/exception.dart'; import 'package:nc_photos/iterable_extension.dart'; -import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/object_extension.dart'; import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util; import 'package:nc_photos/touch_token_manager.dart'; @@ -133,10 +132,9 @@ class FileCacheUpdater { final fileStore = transaction.objectStore(AppDb.file2StoreName); // add files to db - await remote.forEachAsync( - (f) => fileStore.put(AppDbFile2Entry.fromFile(account, f).toJson(), - AppDbFile2Entry.toPrimaryKeyForFile(account, f)), - k.simultaneousQuery); + await Future.wait(remote.map((f) => fileStore.put( + AppDbFile2Entry.fromFile(account, f).toJson(), + AppDbFile2Entry.toPrimaryKeyForFile(account, f)))); // results from remote also contain the dir itself final resultGroup = diff --git a/app/lib/use_case/cache_favorite.dart b/app/lib/use_case/cache_favorite.dart index ca8cd689..bf84419a 100644 --- a/app/lib/use_case/cache_favorite.dart +++ b/app/lib/use_case/cache_favorite.dart @@ -9,7 +9,6 @@ import 'package:nc_photos/di_container.dart'; import 'package:nc_photos/entity/file.dart'; import 'package:nc_photos/event/event.dart'; import 'package:nc_photos/iterable_extension.dart'; -import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/list_util.dart' as list_util; import 'package:nc_photos/use_case/list_favorite_offline.dart'; @@ -42,7 +41,7 @@ class CacheFavorite { (db) => db.transaction(AppDb.file2StoreName, idbModeReadWrite), (transaction) async { final fileStore = transaction.objectStore(AppDb.file2StoreName); - await newFavorites.forEachAsync((f) async { + await Future.wait(newFavorites.map((f) async { _log.info("[call] New favorite: ${f.path}"); try { await fileStore.put(AppDbFile2Entry.fromFile(account, f).toJson(), @@ -53,8 +52,8 @@ class CacheFavorite { e, stackTrace); } - }, k.simultaneousQuery); - await removedFavorites.forEachAsync((f) async { + })); + await Future.wait(removedFavorites.map((f) async { _log.info("[call] Remove favorite: ${f.path}"); try { await fileStore.put(AppDbFile2Entry.fromFile(account, f).toJson(), @@ -65,7 +64,7 @@ class CacheFavorite { e, stackTrace); } - }, k.simultaneousQuery); + })); }, );