- Canais: publicações viram cartões de largura total mantendo todas as funções do balão (reações, resposta, editar, excluir, comentários em thread). Composer de publicação fica restrito a admins no feed; membros comentam via tela de thread. Canais novos usam events_default 0 para permitir comentários e reações. - Ao sair/excluir uma sala, a cópia local é removida do banco imediatamente; salas já deixadas no servidor não apresentam mais erro ao excluir de novo. - Classificação mural/canal carregada direto do sync (room_type em importantStateEvents + postLoad) sem precisar abrir a sala. - Diálogos com raio e padding reduzidos (dialogTheme, text input e ok/cancel). - Ícones do app regenerados (logo_background) e dependência linkify.
95 lines
2.9 KiB
Dart
95 lines
2.9 KiB
Dart
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
|
|
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import 'package:tatchat/l10n/l10n.dart';
|
|
import 'package:tatchat/pages/archive/archive_view.dart';
|
|
import 'package:tatchat/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart';
|
|
import 'package:tatchat/widgets/future_loading_dialog.dart';
|
|
import 'package:tatchat/widgets/matrix.dart';
|
|
import 'package:material_ui/material_ui.dart';
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
class Archive extends StatefulWidget {
|
|
const Archive({super.key});
|
|
|
|
@override
|
|
ArchiveController createState() => ArchiveController();
|
|
}
|
|
|
|
class ArchiveController extends State<Archive> {
|
|
List<ArchivedRoom> archive = [];
|
|
|
|
Future<List<ArchivedRoom>> getArchive(BuildContext context) async {
|
|
if (archive.isNotEmpty) return archive;
|
|
return archive = await Matrix.of(context).client.loadArchiveWithTimeline();
|
|
}
|
|
|
|
Future<void> forgetRoomAction(int i) async {
|
|
await showFutureLoadingDialog(
|
|
context: context,
|
|
future: () async {
|
|
Logs().v('Forget room ${archive.last.room.getLocalizedDisplayname()}');
|
|
await forgetRoom(archive[i].room);
|
|
archive.removeAt(i);
|
|
},
|
|
);
|
|
setState(() {});
|
|
}
|
|
|
|
/// Forgets [room] and treats a room that is already gone on the server as
|
|
/// success, so a leftover local copy can always be removed without errors.
|
|
Future<void> forgetRoom(Room room) async {
|
|
try {
|
|
await room.forget();
|
|
} on MatrixException catch (e, s) {
|
|
if (!{
|
|
MatrixError.M_FORBIDDEN,
|
|
MatrixError.M_NOT_FOUND,
|
|
MatrixError.M_UNKNOWN,
|
|
}.contains(e.error)) {
|
|
Logs().w('Failed to forget room ${room.id}', e, s);
|
|
rethrow;
|
|
}
|
|
Logs().w('Room ${room.id} is already gone, cleaning up locally...', e, s);
|
|
room.client.rooms.remove(room);
|
|
}
|
|
}
|
|
|
|
Future<void> forgetAllAction() async {
|
|
final archive = this.archive;
|
|
if (archive.isEmpty) return;
|
|
if (await showOkCancelAlertDialog(
|
|
useRootNavigator: false,
|
|
context: context,
|
|
title: L10n.of(context).areYouSure,
|
|
okLabel: L10n.of(context).yes,
|
|
cancelLabel: L10n.of(context).cancel,
|
|
message: L10n.of(context).clearArchive,
|
|
) !=
|
|
OkCancelResult.ok) {
|
|
return;
|
|
}
|
|
if (!mounted) return;
|
|
await showFutureLoadingDialog(
|
|
context: context,
|
|
futureWithProgress: (onProgress) async {
|
|
final count = archive.length;
|
|
while (archive.isNotEmpty) {
|
|
onProgress(1 - (archive.length / count));
|
|
Logs().v(
|
|
'Forget room ${archive.last.room.getLocalizedDisplayname()}',
|
|
);
|
|
await forgetRoom(archive.last.room);
|
|
archive.removeLast();
|
|
}
|
|
},
|
|
);
|
|
setState(() {});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => ArchiveView(this);
|
|
}
|