feat: unpin message on redact to avoid pinned redactions
This commit is contained in:
parent
02c8db1c9f
commit
fe624747ca
1 changed files with 15 additions and 2 deletions
|
|
@ -855,7 +855,7 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
future: () async {
|
||||
if (event.status.isSent) {
|
||||
if (event.canRedact) {
|
||||
await event.redactEvent(reason: reason);
|
||||
await redactAndUnpinEvent(event, reason: reason);
|
||||
} else {
|
||||
final client = currentRoomBundle.firstWhere(
|
||||
(cl) => selectedEvents.first.senderId == cl!.userID,
|
||||
|
|
@ -865,7 +865,8 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
return;
|
||||
}
|
||||
final room = client.getRoomById(roomId)!;
|
||||
await Event.fromJson(event.toJson(), room).redactEvent(
|
||||
await redactAndUnpinEvent(
|
||||
Event.fromJson(event.toJson(), room),
|
||||
reason: reason,
|
||||
);
|
||||
}
|
||||
|
|
@ -1204,6 +1205,18 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
);
|
||||
}
|
||||
|
||||
Future<String?> redactAndUnpinEvent(
|
||||
Event event, {
|
||||
String? reason,
|
||||
String? txid,
|
||||
}) async {
|
||||
final events = room.pinnedEventIds
|
||||
..removeWhere((oldEvent) => oldEvent == event.eventId);
|
||||
room.setPinnedEvents(events);
|
||||
|
||||
return await room.redactEvent(event.eventId, reason: reason, txid: txid);
|
||||
}
|
||||
|
||||
Timer? _storeInputTimeoutTimer;
|
||||
static const Duration _storeInputTimeout = Duration(milliseconds: 500);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue