fix: salas removidas de vez, paginação no mural, mídia em largura total e teclado nos comentários

This commit is contained in:
2026-09-14 17:15:52 -03:00
parent 8927e80cce
commit 9d69e833bd
8 changed files with 234 additions and 134 deletions

View File

@@ -12,6 +12,31 @@ import 'package:tatchat/config/app_config.dart';
/// different accounts.
const String roomTypeStateEvent = 'tatuchat.room_type';
/// Leaves the room and removes it from the local database so that it does not
/// reappear on the next sync or app restart.
Future<void> safeLeave(Room room) async {
try {
await room.leave();
} on MatrixException catch (e, s) {
// If the room was already left on the server (e.g. a stale local copy
// reappeared after a restart) the leave request fails, but the user
// intent (room not being listed anymore) is already fulfilled. Clean up
// locally instead of showing an error.
if (!{
MatrixError.M_FORBIDDEN,
MatrixError.M_NOT_FOUND,
MatrixError.M_UNKNOWN,
}.contains(e.error)) {
Logs().w('Failed to leave room ${room.id}', e, s);
rethrow;
}
Logs().w('Room ${room.id} is already gone, cleaning up locally...', e, s);
}
final client = room.client;
await client.database.forgetRoom(room.id);
client.rooms.remove(room);
}
extension RoomTypeExtension on Room {
String? get roomType =>
getState(roomTypeStateEvent)?.content.tryGet<String>('type');