fix for error in join space dialog
This commit is contained in:
parent
96e6d76051
commit
6fc676c5e7
6 changed files with 44 additions and 73 deletions
|
|
@ -393,7 +393,6 @@ class ClientChooserButton extends StatelessWidget {
|
|||
ClassCodeUtil.joinWithClassCodeDialog(
|
||||
context,
|
||||
controller.pangeaController,
|
||||
null,
|
||||
);
|
||||
break;
|
||||
case SettingsAction.findAConversationPartner:
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
// #Pangea
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_roomSubscription?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
// Pangea#
|
||||
|
||||
|
|
@ -108,9 +108,15 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
});
|
||||
rethrow;
|
||||
} finally {
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
// #Pangea
|
||||
if (mounted) {
|
||||
// Pangea#
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
// #Pangea
|
||||
}
|
||||
// Pangea#
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -482,11 +488,11 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
onTapSpaceChild, and they interfere with each other */
|
||||
if (event.isMembershipUpdateByType(
|
||||
Membership.leave,
|
||||
Matrix.of(context).client.userID!,
|
||||
client.userID!,
|
||||
) ||
|
||||
event.isMembershipUpdateByType(
|
||||
Membership.invite,
|
||||
Matrix.of(context).client.userID!,
|
||||
client.userID!,
|
||||
) ||
|
||||
event.isSpaceChildUpdate(activeSpaceId)) {
|
||||
_refresh();
|
||||
|
|
|
|||
|
|
@ -233,10 +233,6 @@ class NewSpaceController extends State<NewSpace> {
|
|||
GoogleAnalytics.createClass(room.name, room.classCode);
|
||||
try {
|
||||
await room.invite(BotName.byEnvironment);
|
||||
await room.setPower(
|
||||
BotName.byEnvironment,
|
||||
ClassDefaultValues.powerLevelOfAdmin,
|
||||
);
|
||||
} catch (err) {
|
||||
ErrorHandler.logError(
|
||||
e: "Failed to invite pangea bot to space ${room.id}",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import 'package:fluffychat/pangea/utils/error_handler.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import '../../widgets/matrix.dart';
|
||||
|
|
@ -132,15 +131,12 @@ class ClassController extends BaseController {
|
|||
await _pangeaController.matrixState.client.joinRoom(classChunk.roomId);
|
||||
|
||||
setActiveSpaceIdInChatListController(classChunk.roomId);
|
||||
|
||||
GoogleAnalytics.joinClass(classCode);
|
||||
|
||||
ClassCodeUtil.messageSnack(
|
||||
context,
|
||||
L10n.of(context)!.welcomeToYourNewClass,
|
||||
);
|
||||
|
||||
context.go("/rooms");
|
||||
return;
|
||||
// P-EPIC
|
||||
// prereq - server needs ability to invite to private room. how?
|
||||
|
|
|
|||
|
|
@ -949,15 +949,18 @@ extension PangeaRoom on Room {
|
|||
return (eventsDefaultPowerLevel ?? 0) >=
|
||||
ClassDefaultValues.powerLevelOfAdmin;
|
||||
}
|
||||
if (spaceChildren.isEmpty) return false;
|
||||
int joinedRooms = 0;
|
||||
for (final child in spaceChildren) {
|
||||
if (child.roomId == null) continue;
|
||||
final Room? room = client.getRoomById(child.roomId!);
|
||||
if (room?.locked == false) {
|
||||
return false;
|
||||
}
|
||||
if (room != null) {
|
||||
joinedRooms += 1;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return joinedRooms > 0 ? true : false;
|
||||
}
|
||||
|
||||
Future<bool> suggestedInSpace(Room space) async {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
import '../controllers/pangea_controller.dart';
|
||||
|
||||
class ClassCodeUtil {
|
||||
|
|
@ -23,59 +21,32 @@ class ClassCodeUtil {
|
|||
.join();
|
||||
}
|
||||
|
||||
static void joinWithClassCodeDialog(
|
||||
BuildContext outerContext,
|
||||
static Future<void> joinWithClassCodeDialog(
|
||||
BuildContext context,
|
||||
PangeaController pangeaController,
|
||||
String? classCode,
|
||||
) {
|
||||
final TextEditingController textFieldController = TextEditingController(
|
||||
text: classCode,
|
||||
) async {
|
||||
final List<String>? classCode = await showTextInputDialog(
|
||||
context: context,
|
||||
title: L10n.of(context)!.joinWithClassCode,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
textFields: [
|
||||
DialogTextField(hintText: L10n.of(context)!.joinWithClassCodeHint),
|
||||
],
|
||||
);
|
||||
if (classCode == null || classCode.single.isEmpty) return;
|
||||
|
||||
showDialog(
|
||||
context: outerContext,
|
||||
useRootNavigator: false,
|
||||
builder: (BuildContext context) => Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
body: AlertDialog(
|
||||
title: Text(L10n.of(context)!.joinWithClassCode),
|
||||
content: TextField(
|
||||
controller: textFieldController,
|
||||
decoration: InputDecoration(
|
||||
hintText: L10n.of(context)!.joinWithClassCodeHint,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(L10n.of(context)!.cancel),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
TextButton(
|
||||
child: Text(L10n.of(context)!.ok),
|
||||
onPressed: () => showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
try {
|
||||
await pangeaController.classController.joinClasswithCode(
|
||||
outerContext,
|
||||
textFieldController.text,
|
||||
);
|
||||
} catch (err) {
|
||||
messageSnack(
|
||||
outerContext,
|
||||
ErrorCopy(outerContext, err).body,
|
||||
);
|
||||
} finally {
|
||||
context.go("/rooms");
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
try {
|
||||
await pangeaController.classController.joinClasswithCode(
|
||||
context,
|
||||
classCode.first,
|
||||
);
|
||||
} catch (err) {
|
||||
messageSnack(
|
||||
context,
|
||||
ErrorCopy(context, err).body,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static messageDialog(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue