fix: Archive
This commit is contained in:
parent
8af9af10ae
commit
eac784e33b
11 changed files with 89 additions and 53 deletions
|
|
@ -630,6 +630,7 @@ class ChatController extends State<Chat> {
|
|||
}
|
||||
|
||||
bool get canRedactSelectedEvents {
|
||||
if (isArchived) return false;
|
||||
final clients = matrix!.currentBundle;
|
||||
for (final event in selectedEvents) {
|
||||
if (event.canRedact == false &&
|
||||
|
|
@ -639,7 +640,9 @@ class ChatController extends State<Chat> {
|
|||
}
|
||||
|
||||
bool get canEditSelectedEvents {
|
||||
if (selectedEvents.length != 1 || !selectedEvents.first.status.isSent) {
|
||||
if (isArchived ||
|
||||
selectedEvents.length != 1 ||
|
||||
!selectedEvents.first.status.isSent) {
|
||||
return false;
|
||||
}
|
||||
return currentRoomBundle
|
||||
|
|
@ -757,6 +760,15 @@ class ChatController extends State<Chat> {
|
|||
return sendEmojiAction(emoji.emoji);
|
||||
}
|
||||
|
||||
void forgetRoom() async {
|
||||
final result = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: room!.forget,
|
||||
);
|
||||
if (result.error != null) return;
|
||||
VRouter.of(context).to('/archive');
|
||||
}
|
||||
|
||||
void typeEmoji(Emoji? emoji) {
|
||||
if (emoji == null) return;
|
||||
final text = sendController.text;
|
||||
|
|
@ -1008,6 +1020,9 @@ class ChatController extends State<Chat> {
|
|||
setState(() => inputText = text);
|
||||
}
|
||||
|
||||
bool get isArchived =>
|
||||
{Membership.leave, Membership.ban}.contains(room?.membership);
|
||||
|
||||
void showEventInfo([Event? event]) =>
|
||||
(event ?? selectedEvents.single).showInfoDialog(context);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,10 @@ class ChatAppBarTitle extends StatelessWidget {
|
|||
'${room.unsafeGetUserFromMemoryOrFallback(directChatMatrixID).mention} ',
|
||||
),
|
||||
)
|
||||
: () => VRouter.of(context).toSegments(['rooms', room.id, 'details']),
|
||||
: controller.isArchived
|
||||
? null
|
||||
: () =>
|
||||
VRouter.of(context).toSegments(['rooms', room.id, 'details']),
|
||||
child: Row(
|
||||
children: [
|
||||
Hero(
|
||||
|
|
|
|||
|
|
@ -108,6 +108,20 @@ class ChatView extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
];
|
||||
} else if (controller.isArchived) {
|
||||
return [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextButton.icon(
|
||||
onPressed: controller.forgetRoom,
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
icon: const Icon(Icons.delete_forever_outlined),
|
||||
label: Text(L10n.of(context)!.delete),
|
||||
),
|
||||
)
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
if (Matrix.of(context).voipPlugin != null &&
|
||||
|
|
|
|||
|
|
@ -21,10 +21,11 @@ class PinnedEvents extends StatelessWidget {
|
|||
BuildContext context, List<Event?> events) async {
|
||||
final eventId = events.length == 1
|
||||
? events.single?.eventId
|
||||
: await showModalActionSheet<String>(
|
||||
: await showConfirmationDialog<String>(
|
||||
context: context,
|
||||
title: L10n.of(context)!.pinMessage,
|
||||
actions: events
|
||||
.map((event) => SheetAction(
|
||||
.map((event) => AlertDialogAction(
|
||||
key: event?.eventId ?? '',
|
||||
label: event?.calcLocalizedBodyFallback(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue