From ec980df11ce1449703415246cd1d47362c3c5998 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 25 Nov 2021 12:05:10 +0000
Subject: [PATCH] Fix wrongly showing unpin in pinned messages tile with no
perms
---
.../views/right_panel/PinnedMessagesCard.tsx | 30 ++++++++++---------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/src/components/views/right_panel/PinnedMessagesCard.tsx b/src/components/views/right_panel/PinnedMessagesCard.tsx
index bb6ddb0f741..72e7f5282de 100644
--- a/src/components/views/right_panel/PinnedMessagesCard.tsx
+++ b/src/components/views/right_panel/PinnedMessagesCard.tsx
@@ -122,24 +122,26 @@ const PinnedMessagesCard = ({ room, onClose }: IProps) => {
if (!pinnedEvents) {
content = ;
} else if (pinnedEvents.length > 0) {
- let onUnpinClicked;
- if (canUnpin) {
- onUnpinClicked = async (event: MatrixEvent) => {
- const pinnedEvents = room.currentState.getStateEvents(EventType.RoomPinnedEvents, "");
- if (pinnedEvents?.getContent()?.pinned) {
- const pinned = pinnedEvents.getContent().pinned;
- const index = pinned.indexOf(event.getId());
- if (index !== -1) {
- pinned.splice(index, 1);
- await cli.sendStateEvent(room.roomId, EventType.RoomPinnedEvents, { pinned }, "");
- }
+ const onUnpinClicked = async (event: MatrixEvent) => {
+ const pinnedEvents = room.currentState.getStateEvents(EventType.RoomPinnedEvents, "");
+ if (pinnedEvents?.getContent()?.pinned) {
+ const pinned = pinnedEvents.getContent().pinned;
+ const index = pinned.indexOf(event.getId());
+ if (index !== -1) {
+ pinned.splice(index, 1);
+ await cli.sendStateEvent(room.roomId, EventType.RoomPinnedEvents, { pinned }, "");
}
- };
- }
+ }
+ };
// show them in reverse, with latest pinned at the top
content = pinnedEvents.filter(Boolean).reverse().map(ev => (
- onUnpinClicked(ev)} />
+ onUnpinClicked(ev) : undefined}
+ />
));
} else {
content =