2022-05-07 12:27:26 +02:00
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
import 'package:nc_photos/di_container.dart';
|
|
|
|
import 'package:nc_photos/entity/local_file.dart';
|
2022-12-16 16:01:04 +01:00
|
|
|
import 'package:np_codegen/np_codegen.dart';
|
2022-05-07 12:27:26 +02:00
|
|
|
|
2022-12-16 16:01:04 +01:00
|
|
|
part 'share_local.g.dart';
|
|
|
|
|
|
|
|
@npLog
|
2022-05-07 12:27:26 +02:00
|
|
|
class ShareLocal {
|
|
|
|
ShareLocal(this._c) : assert(require(_c));
|
|
|
|
|
|
|
|
static bool require(DiContainer c) =>
|
|
|
|
DiContainer.has(c, DiType.localFileRepo);
|
|
|
|
|
|
|
|
Future<void> call(
|
|
|
|
List<LocalFile> files, {
|
|
|
|
LocalFileOnFailureListener? onFailure,
|
|
|
|
}) async {
|
|
|
|
var count = files.length;
|
|
|
|
await _c.localFileRepo.shareFiles(files, onFailure: (f, e, stackTrace) {
|
|
|
|
--count;
|
|
|
|
onFailure?.call(f, e, stackTrace);
|
|
|
|
});
|
|
|
|
_log.info("[call] Shared $count files successfully");
|
|
|
|
}
|
|
|
|
|
|
|
|
final DiContainer _c;
|
|
|
|
}
|