fix: Archive

This commit is contained in:
Krille 2023-01-08 12:32:35 +01:00
commit eac784e33b
11 changed files with 89 additions and 53 deletions

View file

@ -21,7 +21,6 @@ class ChatListItem extends StatelessWidget {
final Room room;
final bool activeChat;
final bool selected;
final Function? onForget;
final void Function()? onTap;
final void Function()? onLongPress;
@ -31,7 +30,6 @@ class ChatListItem extends StatelessWidget {
this.selected = false,
this.onTap,
this.onLongPress,
this.onForget,
Key? key,
}) : super(key: key);
@ -62,35 +60,7 @@ class ChatListItem extends StatelessWidget {
}
if (room.membership == Membership.leave) {
final action = await showModalActionSheet<ArchivedRoomAction>(
context: context,
title: L10n.of(context)!.archivedRoom,
message: L10n.of(context)!.thisRoomHasBeenArchived,
actions: [
SheetAction(
label: L10n.of(context)!.rejoin,
key: ArchivedRoomAction.rejoin,
),
SheetAction(
label: L10n.of(context)!.delete,
key: ArchivedRoomAction.delete,
isDestructiveAction: true,
),
],
);
if (action != null) {
switch (action) {
case ArchivedRoomAction.delete:
await archiveAction(context);
break;
case ArchivedRoomAction.rejoin:
await showFutureLoadingDialog(
context: context,
future: () => room.join(),
);
break;
}
}
VRouter.of(context).toSegments(['archive', room.id]);
}
if (room.membership == Membership.join) {
@ -122,13 +92,10 @@ class ChatListItem extends StatelessWidget {
Future<void> archiveAction(BuildContext context) async {
{
if ([Membership.leave, Membership.ban].contains(room.membership)) {
final success = await showFutureLoadingDialog(
await showFutureLoadingDialog(
context: context,
future: () => room.forget(),
);
if (success.error == null) {
if (onForget != null) onForget!();
}
return;
}
final confirmed = await showOkCancelAlertDialog(

View file

@ -66,6 +66,16 @@ class ClientChooserButton extends StatelessWidget {
],
),
),
PopupMenuItem(
value: SettingsAction.archive,
child: Row(
children: [
const Icon(Icons.archive_outlined),
const SizedBox(width: 18),
Text(L10n.of(context)!.archive),
],
),
),
PopupMenuItem(
value: SettingsAction.settings,
child: Row(
@ -259,6 +269,9 @@ class ClientChooserButton extends StatelessWidget {
case SettingsAction.settings:
VRouter.of(context).to('/settings');
break;
case SettingsAction.archive:
VRouter.of(context).to('/archive');
break;
}
}
}
@ -336,4 +349,5 @@ enum SettingsAction {
newSpace,
invite,
settings,
archive,
}