mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-25 10:58:50 +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));
|
album: widget.album));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onAppBarConvertBasicPressed(BuildContext context) {
|
Future<void> _onAppBarConvertBasicPressed(BuildContext context) async {
|
||||||
showDialog(
|
final result = await showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
title: Text(L10n.global().convertBasicAlbumConfirmationDialogTitle),
|
title: Text(L10n.global().convertBasicAlbumConfirmationDialogTitle),
|
||||||
|
@ -361,38 +361,39 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
).then((value) {
|
);
|
||||||
if (value != true) {
|
if (result != true) {
|
||||||
return;
|
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(
|
} catch (e, stackTrace) {
|
||||||
"[_onAppBarConvertBasicPressed] Converting album '${_album!.name}' to static");
|
_log.shout(
|
||||||
final albumRepo = AlbumRepo(AlbumCachedDataSource());
|
"[_onAppBarConvertBasicPressed] Failed while converting to basic album",
|
||||||
UpdateAlbum(albumRepo)(
|
e,
|
||||||
widget.account,
|
stackTrace);
|
||||||
_album!.copyWith(
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
provider: AlbumStaticProvider(items: _sortedItems),
|
content: Text(exception_util.toUserString(e)),
|
||||||
coverProvider: AlbumAutoCoverProvider(),
|
duration: k.snackBarDurationNormal,
|
||||||
),
|
));
|
||||||
).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,
|
|
||||||
));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSelectionAppBarSharePressed(BuildContext context) {
|
void _onSelectionAppBarSharePressed(BuildContext context) {
|
||||||
|
|
Loading…
Reference in a new issue