Finish fixing capacity enforcement bugs
This commit is contained in:
parent
db61c1f1cf
commit
8cc377a3f4
11 changed files with 42 additions and 31 deletions
|
|
@ -68,7 +68,10 @@ class ChatPage extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId);
|
||||
if (room == null) {
|
||||
// #Pangea
|
||||
if (room == null || room.membership == Membership.leave) {
|
||||
// if (room == null) {
|
||||
// Pangea#
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(L10n.of(context)!.oopsSomethingWentWrong)),
|
||||
body: Center(
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import 'package:fluffychat/widgets/unread_rooms_badge.dart';
|
|||
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:matrix/matrix.dart';
|
||||
|
||||
import '../../utils/stream_extension.dart';
|
||||
|
|
@ -151,6 +152,11 @@ class ChatView extends StatelessWidget {
|
|||
context: context,
|
||||
future: () => controller.room.join(),
|
||||
);
|
||||
// #Pangea
|
||||
controller.room.leaveIfFull().then(
|
||||
(full) => full ? context.go('/rooms') : null,
|
||||
);
|
||||
// Pangea#
|
||||
}
|
||||
final bottomSheetPadding = FluffyThemes.isColumnMode(context) ? 16.0 : 8.0;
|
||||
final scrollUpBannerEventId = controller.scrollUpBannerEventId;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@ class ChatDetailsView extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final room = Matrix.of(context).client.getRoomById(controller.roomId!);
|
||||
if (room == null) {
|
||||
// #Pangea
|
||||
if (room == null || room.membership == Membership.leave) {
|
||||
// if (room == null) {
|
||||
// Pangea#
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(L10n.of(context)!.oopsSomethingWentWrong),
|
||||
|
|
|
|||
|
|
@ -180,13 +180,7 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
// #Pangea
|
||||
final room = client.getRoomById(spaceChild.roomId);
|
||||
if (room != null && (await room.leaveIfFull())) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
duration: const Duration(seconds: 10),
|
||||
content: Text(L10n.of(context)!.roomFull),
|
||||
),
|
||||
);
|
||||
return;
|
||||
throw L10n.of(context)!.roomFull;
|
||||
}
|
||||
// Pangea#
|
||||
},
|
||||
|
|
@ -207,17 +201,11 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
);
|
||||
await room.join();
|
||||
await waitForRoom;
|
||||
if (await room.leaveIfFull()) {
|
||||
throw L10n.of(context)!.roomFull;
|
||||
}
|
||||
},
|
||||
);
|
||||
if (await room.leaveIfFull()) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
duration: const Duration(seconds: 10),
|
||||
content: Text(L10n.of(context)!.roomFull),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (joinResult.error != null) return;
|
||||
}
|
||||
// Pangea#
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:fluffychat/pages/chat/send_file_dialog.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -63,6 +64,9 @@ void onChatTap(Room room, BuildContext context) async {
|
|||
room.id,
|
||||
join: true,
|
||||
);
|
||||
if (await room.leaveIfFull()) {
|
||||
throw L10n.of(context)!.roomFull;
|
||||
}
|
||||
await room.join();
|
||||
await waitForRoom;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -143,14 +143,16 @@ class ClassController extends BaseController {
|
|||
);
|
||||
}
|
||||
|
||||
// If the room is full, leave
|
||||
final room =
|
||||
_pangeaController.matrixState.client.getRoomById(classChunk.roomId);
|
||||
if (room != null && (await room.leaveIfFull())) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
duration: const Duration(seconds: 10),
|
||||
content: Text(L10n.of(context)!.roomFull),
|
||||
),
|
||||
if (room == null) {
|
||||
return;
|
||||
}
|
||||
if ((await room.leaveIfFull())) {
|
||||
ClassCodeUtil.messageSnack(
|
||||
context,
|
||||
L10n.of(context)!.roomFull,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ part of "pangea_room_extension.dart";
|
|||
|
||||
extension EventsRoomExtension on Room {
|
||||
Future<bool> _leaveIfFull() async {
|
||||
await postLoad();
|
||||
if (!isRoomAdmin &&
|
||||
(_capacity != null) &&
|
||||
(await _numNonAdmins) >= (int.parse(_capacity!))) {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ void chatListHandleSpaceTap(
|
|||
context: context,
|
||||
future: () async {
|
||||
await space.join();
|
||||
if (await space.leaveIfFull()) {
|
||||
throw L10n.of(context)!.roomFull;
|
||||
}
|
||||
await space.postLoad();
|
||||
setActiveSpaceAndCloseChat();
|
||||
},
|
||||
|
|
@ -65,6 +68,9 @@ void chatListHandleSpaceTap(
|
|||
context: context,
|
||||
future: () async {
|
||||
await space.join();
|
||||
if (await space.leaveIfFull()) {
|
||||
throw L10n.of(context)!.roomFull;
|
||||
}
|
||||
if (space.isSpace) {
|
||||
await space.joinAnalyticsRoomsInSpace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ abstract class ClientManager {
|
|||
PangeaEventTypes.botOptions,
|
||||
EventTypes.RoomTopic,
|
||||
EventTypes.RoomAvatar,
|
||||
PangeaEventTypes.capacity,
|
||||
// Pangea#
|
||||
},
|
||||
logLevel: kReleaseMode ? Level.warning : Level.verbose,
|
||||
|
|
|
|||
|
|
@ -159,7 +159,10 @@ class UrlLauncher {
|
|||
room = matrix.client.getRoomById(roomId!);
|
||||
}
|
||||
servers.addAll(identityParts.via);
|
||||
if (room != null) {
|
||||
// #Pangea
|
||||
if (room != null && room.membership != Membership.leave) {
|
||||
// if (room != null) {
|
||||
// Pangea#
|
||||
if (room.isSpace) {
|
||||
// TODO: Implement navigate to space
|
||||
context.go('/rooms/${room.id}');
|
||||
|
|
|
|||
|
|
@ -47,12 +47,6 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
// #Pangea
|
||||
final room = client.getRoomById(roomId);
|
||||
if (room != null && (await room.leaveIfFull())) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
duration: const Duration(seconds: 10),
|
||||
content: Text(L10n.of(context)!.roomFull),
|
||||
),
|
||||
);
|
||||
throw L10n.of(context)!.roomFull;
|
||||
}
|
||||
// Pangea#
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue