2022-01-25 18:08:13 +08:00
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
import 'package:nc_photos/account.dart';
|
2023-12-06 22:05:33 +08:00
|
|
|
import 'package:nc_photos/db/entity_converter.dart';
|
2022-01-25 18:08:13 +08:00
|
|
|
import 'package:nc_photos/di_container.dart';
|
2022-12-16 23:01:04 +08:00
|
|
|
import 'package:np_codegen/np_codegen.dart';
|
2024-01-18 01:17:53 +08:00
|
|
|
import 'package:np_db/np_db.dart';
|
2022-01-25 18:08:13 +08:00
|
|
|
|
2022-12-16 23:01:04 +08:00
|
|
|
part 'cache_favorite.g.dart';
|
|
|
|
|
|
|
|
@npLog
|
2022-01-25 18:08:13 +08:00
|
|
|
class CacheFavorite {
|
2023-12-06 22:05:33 +08:00
|
|
|
const CacheFavorite(this._c);
|
2022-01-25 18:08:13 +08:00
|
|
|
|
2022-07-28 03:00:42 +08:00
|
|
|
/// Cache favorites using results from remote
|
|
|
|
///
|
2024-01-18 01:17:53 +08:00
|
|
|
/// Return the fileIds of the affected files
|
|
|
|
Future<DbSyncIdResult> call(
|
|
|
|
Account account, Iterable<int> remoteFileIds) async {
|
2022-07-28 03:00:42 +08:00
|
|
|
_log.info("[call] Cache favorites");
|
2024-01-31 01:11:21 +08:00
|
|
|
return _c.npDb.syncFavoriteFiles(
|
2023-12-06 22:05:33 +08:00
|
|
|
account: account.toDb(),
|
|
|
|
favoriteFileIds: remoteFileIds.toList(),
|
|
|
|
);
|
2022-01-25 18:08:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
final DiContainer _c;
|
|
|
|
}
|