Merge pull request #4798 from pangeachat/4788-admin-encounters-error-if-taken-back-to-course-page-after-leaving-chat-joined-via-the-ojd-activities-list
fix: use chat view's context when leaving activity via header button
This commit is contained in:
commit
b23d4332cb
4 changed files with 37 additions and 34 deletions
|
|
@ -2305,6 +2305,36 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onLeave() async {
|
||||
final parentSpaceId = room.courseParent?.id;
|
||||
final confirmed = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).areYouSure,
|
||||
message: L10n.of(context).leaveRoomDescription,
|
||||
okLabel: L10n.of(context).leave,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
isDestructive: true,
|
||||
);
|
||||
if (confirmed != OkCancelResult.ok) return;
|
||||
final result = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: widget.room.leave,
|
||||
);
|
||||
|
||||
if (result.isError) return;
|
||||
final r = Matrix.of(context).client.getRoomById(widget.room.id);
|
||||
if (r != null && r.membership != Membership.leave) {
|
||||
await Matrix.of(context).client.waitForRoomInSync(
|
||||
widget.room.id,
|
||||
leave: true,
|
||||
);
|
||||
}
|
||||
|
||||
context.go(
|
||||
parentSpaceId != null ? '/rooms/spaces/$parentSpaceId' : '/rooms',
|
||||
);
|
||||
}
|
||||
// Pangea#
|
||||
|
||||
late final ValueNotifier<bool> _displayChatDetailsColumn;
|
||||
|
|
|
|||
|
|
@ -147,7 +147,10 @@ class ChatView extends StatelessWidget {
|
|||
if (controller.room.showActivityChatUI) {
|
||||
return [
|
||||
ActivityMenuButton(controller: controller),
|
||||
ActivitySessionPopupMenu(controller.room),
|
||||
ActivitySessionPopupMenu(
|
||||
controller.room,
|
||||
onLeave: controller.onLeave,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,15 +6,14 @@ import 'package:matrix/matrix.dart';
|
|||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pages/chat_details/chat_download_provider.dart';
|
||||
import 'package:fluffychat/pangea/activity_sessions/activity_room_extension.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
|
||||
enum ActivityPopupMenuActions { invite, leave, download }
|
||||
|
||||
class ActivitySessionPopupMenu extends StatefulWidget {
|
||||
final Room room;
|
||||
final VoidCallback onLeave;
|
||||
|
||||
const ActivitySessionPopupMenu(this.room, {super.key});
|
||||
const ActivitySessionPopupMenu(this.room, {required this.onLeave, super.key});
|
||||
|
||||
@override
|
||||
ActivitySessionPopupMenuState createState() =>
|
||||
|
|
@ -30,28 +29,7 @@ class ActivitySessionPopupMenuState extends State<ActivitySessionPopupMenu>
|
|||
onSelected: (choice) async {
|
||||
switch (choice) {
|
||||
case ActivityPopupMenuActions.leave:
|
||||
final parentSpaceId = widget.room.courseParent?.id;
|
||||
final router = GoRouter.of(context);
|
||||
final confirmed = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).areYouSure,
|
||||
message: L10n.of(context).leaveRoomDescription,
|
||||
okLabel: L10n.of(context).leave,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
isDestructive: true,
|
||||
);
|
||||
if (confirmed != OkCancelResult.ok) return;
|
||||
final result = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => widget.room.leave(),
|
||||
);
|
||||
if (result.error == null) {
|
||||
router.go(
|
||||
parentSpaceId != null
|
||||
? '/rooms/spaces/$parentSpaceId'
|
||||
: '/rooms',
|
||||
);
|
||||
}
|
||||
widget.onLeave();
|
||||
break;
|
||||
case ActivityPopupMenuActions.invite:
|
||||
context.go(
|
||||
|
|
|
|||
|
|
@ -57,14 +57,6 @@ class PutAnalyticsController {
|
|||
}
|
||||
|
||||
void initialize() {
|
||||
final Room? analyticsRoom = _client.analyticsRoomLocal(
|
||||
_pangeaController.languageController.userL2!,
|
||||
);
|
||||
|
||||
if (analyticsRoom != null) {
|
||||
savedActivitiesNotifier.value = analyticsRoom.activityRoomIds;
|
||||
}
|
||||
|
||||
_languageStream ??= _pangeaController.userController.languageStream.stream
|
||||
.listen(_onUpdateLanguages);
|
||||
_refreshAnalyticsIfOutdated();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue