mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 14:56:20 +01:00
Refactoring: extract create share fn
This commit is contained in:
parent
20dfc2e00e
commit
19367e2a0d
2 changed files with 11 additions and 1 deletions
|
@ -2,6 +2,15 @@ import 'package:nc_photos/account.dart';
|
||||||
import 'package:nc_photos/entity/file.dart';
|
import 'package:nc_photos/entity/file.dart';
|
||||||
import 'package:nc_photos/entity/share.dart';
|
import 'package:nc_photos/entity/share.dart';
|
||||||
|
|
||||||
|
class CreateUserShare {
|
||||||
|
const CreateUserShare(this.shareRepo);
|
||||||
|
|
||||||
|
Future<Share> call(Account account, File file, String shareWith) =>
|
||||||
|
shareRepo.create(account, file, shareWith);
|
||||||
|
|
||||||
|
final ShareRepo shareRepo;
|
||||||
|
}
|
||||||
|
|
||||||
class CreateLinkShare {
|
class CreateLinkShare {
|
||||||
const CreateLinkShare(this.shareRepo);
|
const CreateLinkShare(this.shareRepo);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import 'package:nc_photos/exception_util.dart' as exception_util;
|
||||||
import 'package:nc_photos/iterable_extension.dart';
|
import 'package:nc_photos/iterable_extension.dart';
|
||||||
import 'package:nc_photos/k.dart' as k;
|
import 'package:nc_photos/k.dart' as k;
|
||||||
import 'package:nc_photos/snack_bar_manager.dart';
|
import 'package:nc_photos/snack_bar_manager.dart';
|
||||||
|
import 'package:nc_photos/use_case/create_share.dart';
|
||||||
|
|
||||||
class ShareAlbumDialog extends StatefulWidget {
|
class ShareAlbumDialog extends StatefulWidget {
|
||||||
const ShareAlbumDialog({
|
const ShareAlbumDialog({
|
||||||
|
@ -146,7 +147,7 @@ class _ShareAlbumDialogState extends State<ShareAlbumDialog> {
|
||||||
if (share == null) {
|
if (share == null) {
|
||||||
// create new share
|
// create new share
|
||||||
try {
|
try {
|
||||||
final newShare = await shareRepo.create(
|
final newShare = await CreateUserShare(shareRepo)(
|
||||||
widget.account, widget.file, sharee.shareWith);
|
widget.account, widget.file, sharee.shareWith);
|
||||||
_overrideSharee[sharee.shareWith] = newShare;
|
_overrideSharee[sharee.shareWith] = newShare;
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
|
|
Loading…
Reference in a new issue