Don't return to archived space view

This commit is contained in:
Kelrap 2024-06-03 11:28:12 -04:00
parent 5feaed1d42
commit 2127277d81
6 changed files with 31 additions and 9 deletions

View file

@ -454,7 +454,11 @@ class ChatController extends State<ChatPageWithRoom>
}
}
timeline!.requestKeys(onlineKeyBackupOnly: false);
if (room.markedUnread) room.markUnread(false);
if (!room.isSpace &&
room.membership == Membership.join &&
room.markedUnread) {
room.markUnread(false);
}
// when the scroll controller is attached we want to scroll to an event id, if specified
// and update the scroll controller...which will trigger a request history, if the

View file

@ -515,7 +515,8 @@ class ChatListController extends State<ChatList>
//#Pangea
classStream = pangeaController.classController.stateStream.listen((event) {
if (event["activeSpaceId"] != null && mounted) {
// if (event["activeSpaceId"] != null && mounted) {
if (mounted) {
setActiveSpace(event["activeSpaceId"]);
}
});
@ -769,10 +770,13 @@ class ChatListController extends State<ChatList>
while (selectedRoomIds.isNotEmpty) {
final roomId = selectedRoomIds.first;
try {
if (client.getRoomById(roomId)!.isUnread) {
await client.getRoomById(roomId)!.markUnread(false);
final room = client.getRoomById(roomId);
if (!room!.isSpace &&
room.membership == Membership.join &&
room.isUnread) {
await room.markUnread(false);
}
await client.getRoomById(roomId)!.leave();
await room.leave();
} finally {
toggleSelection(roomId);
}

View file

@ -261,6 +261,7 @@ class _SpaceViewState extends State<SpaceView> {
? L10n.of(context)!.archiveSpace
: L10n.of(context)!.archive,
icon: Icons.architecture_outlined,
isDestructiveAction: true,
),
// Pangea#
if (room != null)

View file

@ -46,7 +46,9 @@ void onChatTap(Room room, BuildContext context) async {
}
if (inviteAction == InviteActions.decline) {
// #Pangea
if (room.isUnread) {
if (!room.isSpace &&
room.membership == Membership.join &&
room.isUnread) {
await room.markUnread(false);
}
// Pangea#

View file

@ -27,7 +27,7 @@ class ClassController extends BaseController {
_pangeaController = pangeaController;
}
setActiveSpaceIdInChatListController(String classId) {
setActiveSpaceIdInChatListController(String? classId) {
setState(data: {"activeSpaceId": classId});
}

View file

@ -12,6 +12,7 @@ import 'package:fluffychat/pangea/models/class_model.dart';
import 'package:fluffychat/pangea/models/tokens_event_content_model.dart';
import 'package:fluffychat/pangea/utils/bot_name.dart';
import 'package:fluffychat/pangea/utils/error_handler.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -823,7 +824,7 @@ extension PangeaRoom on Room {
for (final student in students) {
await kick(student.id);
}
if (isUnread) {
if (!isSpace && membership == Membership.join && isUnread) {
await markUnread(false);
}
await leave();
@ -850,6 +851,10 @@ extension PangeaRoom on Room {
await archive();
},
);
MatrixState.pangeaController.classController
.setActiveSpaceIdInChatListController(
null,
);
return success.error == null;
}
@ -869,7 +874,9 @@ extension PangeaRoom on Room {
future: () async {
final List<Room> children = await getChildRooms();
for (final Room child in children) {
if (child.isUnread) {
if (!child.isSpace &&
child.membership == Membership.join &&
child.isUnread) {
await child.markUnread(false);
}
await child.leave();
@ -877,6 +884,10 @@ extension PangeaRoom on Room {
await leave();
},
);
MatrixState.pangeaController.classController
.setActiveSpaceIdInChatListController(
null,
);
return success.error == null;
}