mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-27 17:34:44 +01:00
Open the new album after added to collection
This commit is contained in:
parent
5e8c8a1fde
commit
598f583686
3 changed files with 40 additions and 10 deletions
|
@ -1,18 +1,28 @@
|
|||
import 'package:nc_photos/account.dart';
|
||||
import 'package:nc_photos/entity/album.dart';
|
||||
import 'package:nc_photos/entity/file.dart';
|
||||
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
||||
import 'package:nc_photos/use_case/ls_single_file.dart';
|
||||
import 'package:nc_photos/use_case/move.dart';
|
||||
|
||||
/// Import a shared album from the pending dir to the library
|
||||
class ImportPendingSharedAlbum {
|
||||
ImportPendingSharedAlbum(this.fileRepo);
|
||||
const ImportPendingSharedAlbum(this.fileRepo, this.albumRepo);
|
||||
|
||||
Future<void> call(Account account, File albumFile) => Move(fileRepo)(
|
||||
account,
|
||||
albumFile,
|
||||
"${remote_storage_util.getRemoteAlbumsDir(account)}/${albumFile.filename}",
|
||||
shouldCreateMissingDir: true,
|
||||
);
|
||||
Future<Album> call(Account account, Album album) async {
|
||||
final destination =
|
||||
"${remote_storage_util.getRemoteAlbumsDir(account)}/${album.albumFile!.filename}";
|
||||
await Move(fileRepo)(
|
||||
account,
|
||||
album.albumFile!,
|
||||
destination,
|
||||
shouldCreateMissingDir: true,
|
||||
);
|
||||
final newAlbumFile = await LsSingleFile(fileRepo)(account, destination);
|
||||
final newAlbum = await albumRepo.get(account, newAlbumFile);
|
||||
return newAlbum;
|
||||
}
|
||||
|
||||
final FileRepo fileRepo;
|
||||
final AlbumRepo albumRepo;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
|||
import 'package:nc_photos/use_case/import_pending_shared_album.dart';
|
||||
import 'package:nc_photos/use_case/update_album.dart';
|
||||
import 'package:nc_photos/widget/album_browser_app_bar.dart';
|
||||
import 'package:nc_photos/widget/album_browser_util.dart' as album_browser_util;
|
||||
import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart';
|
||||
import 'package:nc_photos/widget/selection_app_bar.dart';
|
||||
import 'package:nc_photos/widget/zoom_menu_button.dart';
|
||||
|
@ -231,12 +232,14 @@ mixin AlbumBrowserMixin<T extends StatefulWidget>
|
|||
|
||||
void _onAddToCollectionPressed(
|
||||
BuildContext context, Account account, Album album) async {
|
||||
Navigator.of(context).pop();
|
||||
Album? newAlbum;
|
||||
try {
|
||||
await NotifiedAction(
|
||||
() async {
|
||||
const fileRepo = FileRepo(FileWebdavDataSource());
|
||||
await ImportPendingSharedAlbum(fileRepo)(account, album.albumFile!);
|
||||
final fileRepo = FileRepo(FileCachedDataSource(AppDb()));
|
||||
final albumRepo = AlbumRepo(AlbumCachedDataSource(AppDb()));
|
||||
newAlbum = await ImportPendingSharedAlbum(fileRepo, albumRepo)(
|
||||
account, album);
|
||||
},
|
||||
L10n.global().addToCollectionProcessingNotification(album.name),
|
||||
L10n.global().addToCollectionSuccessNotification(album.name),
|
||||
|
@ -248,6 +251,9 @@ mixin AlbumBrowserMixin<T extends StatefulWidget>
|
|||
e,
|
||||
stackTrace);
|
||||
}
|
||||
if (newAlbum != null) {
|
||||
album_browser_util.pushReplacement(context, account, newAlbum!);
|
||||
}
|
||||
}
|
||||
|
||||
String? _coverPreviewUrl;
|
||||
|
|
|
@ -15,3 +15,17 @@ Future<void> push(BuildContext context, Account account, Album album) {
|
|||
arguments: DynamicAlbumBrowserArguments(account, album));
|
||||
}
|
||||
}
|
||||
|
||||
/// Push the corresponding browser route for this album and replace the current
|
||||
/// route
|
||||
Future<void> pushReplacement(
|
||||
BuildContext context, Account account, Album album) {
|
||||
if (album.provider is AlbumStaticProvider) {
|
||||
return Navigator.of(context).pushReplacementNamed(AlbumBrowser.routeName,
|
||||
arguments: AlbumBrowserArguments(account, album));
|
||||
} else {
|
||||
return Navigator.of(context).pushReplacementNamed(
|
||||
DynamicAlbumBrowser.routeName,
|
||||
arguments: DynamicAlbumBrowserArguments(account, album));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue