don't change add to space toggle value if error when trying to add
This commit is contained in:
parent
63f6dcc32d
commit
1d507226f3
3 changed files with 17 additions and 2 deletions
|
|
@ -232,6 +232,7 @@ class PangeaController {
|
|||
if (space.canInvite && !userIds.contains(BotName.byEnvironment)) {
|
||||
try {
|
||||
await space.invite(BotName.byEnvironment);
|
||||
await space.postLoad();
|
||||
await space.setPower(
|
||||
BotName.byEnvironment,
|
||||
ClassDefaultValues.powerLevelOfAdmin,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:collection/collection.dart';
|
|||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
|
|
@ -134,6 +135,13 @@ class AddToSpaceState extends State<AddToSpaceToggles> {
|
|||
future: () => add
|
||||
? _addSingleSpace(room!.id, possibleParent)
|
||||
: possibleParent.removeSpaceChild(room!.id),
|
||||
onError: (e) {
|
||||
// if error occurs, do not change value of toggle
|
||||
add = !add;
|
||||
return (e as Object?)?.toLocalizedString(context) ??
|
||||
e?.toString() ??
|
||||
L10n.of(context)!.oopsSomethingWentWrong;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -268,8 +268,14 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
LoadingDialog.defaultTitle = L10n.of(context)!.loadingPleaseWait;
|
||||
LoadingDialog.defaultBackLabel = L10n.of(context)!.close;
|
||||
LoadingDialog.defaultOnError =
|
||||
(e) => (e as Object?)!.toLocalizedString(context);
|
||||
// #Pangea
|
||||
// LoadingDialog.defaultOnError =
|
||||
// (e) => (e as Object?)!.toLocalizedString(context);
|
||||
LoadingDialog.defaultOnError = (e) =>
|
||||
(e as Object?)?.toLocalizedString(context) ??
|
||||
e?.toString() ??
|
||||
L10n.of(context)!.oopsSomethingWentWrong;
|
||||
// Pangea#
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue