import 'dart:async'; import 'package:logging/logging.dart'; import 'package:nc_photos/account.dart'; import 'package:nc_photos/entity/recognize_face.dart'; import 'package:nc_photos/entity/recognize_face_item.dart'; import 'package:np_codegen/np_codegen.dart'; import 'package:np_common/type.dart'; part 'repo.g.dart'; abstract class RecognizeFaceRepo { /// Query all [RecognizeFace]s belonging to [account] Stream> getFaces(Account account); /// Query all items belonging to [face] Stream> getItems(Account account, RecognizeFace face); /// Query all items belonging to each face Stream>> getMultiFaceItems( Account account, List faces, { ErrorWithValueHandler? onError, }); } /// A repo that simply relay the call to the backed [NcAlbumDataSource] @npLog class BasicRecognizeFaceRepo implements RecognizeFaceRepo { const BasicRecognizeFaceRepo(this.dataSrc); @override Stream> getFaces(Account account) async* { yield await dataSrc.getFaces(account); } @override Stream> getItems( Account account, RecognizeFace face) async* { yield await dataSrc.getItems(account, face); } @override Stream>> getMultiFaceItems( Account account, List faces, { ErrorWithValueHandler? onError, }) async* { yield await dataSrc.getMultiFaceItems(account, faces, onError: onError); } final RecognizeFaceDataSource dataSrc; } abstract class RecognizeFaceDataSource { /// Query all [RecognizeFace]s belonging to [account] Future> getFaces(Account account); /// Query all items belonging to [face] Future> getItems(Account account, RecognizeFace face); /// Query all items belonging to each face Future>> getMultiFaceItems( Account account, List faces, { ErrorWithValueHandler? onError, }); /// Query the last items belonging to each face Future> getMultiFaceLastItems( Account account, List faces, { ErrorWithValueHandler? onError, }); }