chore: display loading during image upload (#3503)
This commit is contained in:
parent
e59e314628
commit
cc9fa75c34
2 changed files with 36 additions and 14 deletions
|
|
@ -172,6 +172,7 @@ class ActivityPlannerBuilderState extends State<ActivityPlannerBuilder> {
|
|||
if (mounted) {
|
||||
setState(() {
|
||||
avatar = bytes;
|
||||
imageURL = null;
|
||||
filename = photo.singleOrNull?.name;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,22 +56,43 @@ class ActivitySuggestionDialogState extends State<ActivitySuggestionDialog> {
|
|||
: MediaQuery.of(context).size.width;
|
||||
|
||||
Future<void> _launchActivity() async {
|
||||
if (widget.onLaunch != null) {
|
||||
await widget.controller.updateImageURL();
|
||||
widget.onLaunch!.call();
|
||||
Navigator.of(context).pop();
|
||||
} else if (widget.controller.room != null &&
|
||||
!widget.controller.room!.isSpace) {
|
||||
final resp = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: widget.controller.launchToRoom,
|
||||
);
|
||||
if (!resp.isError) {
|
||||
context.go("/rooms/${widget.controller.room!.id}");
|
||||
try {
|
||||
setState(() {
|
||||
_loading = true;
|
||||
_error = null;
|
||||
});
|
||||
|
||||
if (widget.onLaunch != null) {
|
||||
widget.onLaunch!.call();
|
||||
Navigator.of(context).pop();
|
||||
} else if (widget.controller.room != null &&
|
||||
!widget.controller.room!.isSpace) {
|
||||
final resp = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: widget.controller.launchToRoom,
|
||||
);
|
||||
if (!resp.isError) {
|
||||
context.go("/rooms/${widget.controller.room!.id}");
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} else {
|
||||
_setPageMode(_PageMode.roomSelection);
|
||||
}
|
||||
} catch (e, s) {
|
||||
_error = e;
|
||||
ErrorHandler.logError(
|
||||
e: e,
|
||||
s: s,
|
||||
data: {
|
||||
"request": widget.controller.updatedRequest.toJson(),
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
_setPageMode(_PageMode.roomSelection);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue