mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 02:48:54 +01:00
Flatten future
This commit is contained in:
parent
0a6a90f963
commit
15d9d6edee
1 changed files with 34 additions and 33 deletions
|
@ -340,8 +340,8 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
album: widget.album));
|
||||
}
|
||||
|
||||
void _onAppBarConvertBasicPressed(BuildContext context) {
|
||||
showDialog(
|
||||
Future<void> _onAppBarConvertBasicPressed(BuildContext context) async {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(L10n.global().convertBasicAlbumConfirmationDialogTitle),
|
||||
|
@ -361,38 +361,39 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
|||
),
|
||||
],
|
||||
),
|
||||
).then((value) {
|
||||
if (value != true) {
|
||||
return;
|
||||
);
|
||||
if (result != true) {
|
||||
return;
|
||||
}
|
||||
_log.info(
|
||||
"[_onAppBarConvertBasicPressed] Converting album '${_album!.name}' to static");
|
||||
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
||||
try {
|
||||
await UpdateAlbum(albumRepo)(
|
||||
widget.account,
|
||||
_album!.copyWith(
|
||||
provider: AlbumStaticProvider(
|
||||
items: _sortedItems,
|
||||
),
|
||||
coverProvider: AlbumAutoCoverProvider(),
|
||||
));
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(L10n.global().convertBasicAlbumSuccessNotification),
|
||||
duration: k.snackBarDurationNormal,
|
||||
));
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
_log.info(
|
||||
"[_onAppBarConvertBasicPressed] Converting album '${_album!.name}' to static");
|
||||
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
||||
UpdateAlbum(albumRepo)(
|
||||
widget.account,
|
||||
_album!.copyWith(
|
||||
provider: AlbumStaticProvider(items: _sortedItems),
|
||||
coverProvider: AlbumAutoCoverProvider(),
|
||||
),
|
||||
).then((value) {
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(L10n.global().convertBasicAlbumSuccessNotification),
|
||||
duration: k.snackBarDurationNormal,
|
||||
));
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}).catchError((e, stacktrace) {
|
||||
_log.shout(
|
||||
"[_onAppBarConvertBasicPressed] Failed while converting to basic album",
|
||||
e,
|
||||
stacktrace);
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(exception_util.toUserString(e)),
|
||||
duration: k.snackBarDurationNormal,
|
||||
));
|
||||
});
|
||||
});
|
||||
} catch (e, stackTrace) {
|
||||
_log.shout(
|
||||
"[_onAppBarConvertBasicPressed] Failed while converting to basic album",
|
||||
e,
|
||||
stackTrace);
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(exception_util.toUserString(e)),
|
||||
duration: k.snackBarDurationNormal,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
void _onSelectionAppBarSharePressed(BuildContext context) {
|
||||
|
|
Loading…
Reference in a new issue