You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-04 11:51:45 +03:00 
			
		
		
		
	Fix wrongly showing unpin in pinned messages tile with no perms (#7197)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							ea97c416f5
						
					
				
				
					commit
					508d4d70b6
				
			@@ -122,24 +122,26 @@ const PinnedMessagesCard = ({ room, onClose }: IProps) => {
 | 
				
			|||||||
    if (!pinnedEvents) {
 | 
					    if (!pinnedEvents) {
 | 
				
			||||||
        content = <Spinner />;
 | 
					        content = <Spinner />;
 | 
				
			||||||
    } else if (pinnedEvents.length > 0) {
 | 
					    } else if (pinnedEvents.length > 0) {
 | 
				
			||||||
        let onUnpinClicked;
 | 
					        const onUnpinClicked = async (event: MatrixEvent) => {
 | 
				
			||||||
        if (canUnpin) {
 | 
					            const pinnedEvents = room.currentState.getStateEvents(EventType.RoomPinnedEvents, "");
 | 
				
			||||||
            onUnpinClicked = async (event: MatrixEvent) => {
 | 
					            if (pinnedEvents?.getContent()?.pinned) {
 | 
				
			||||||
                const pinnedEvents = room.currentState.getStateEvents(EventType.RoomPinnedEvents, "");
 | 
					                const pinned = pinnedEvents.getContent().pinned;
 | 
				
			||||||
                if (pinnedEvents?.getContent()?.pinned) {
 | 
					                const index = pinned.indexOf(event.getId());
 | 
				
			||||||
                    const pinned = pinnedEvents.getContent().pinned;
 | 
					                if (index !== -1) {
 | 
				
			||||||
                    const index = pinned.indexOf(event.getId());
 | 
					                    pinned.splice(index, 1);
 | 
				
			||||||
                    if (index !== -1) {
 | 
					                    await cli.sendStateEvent(room.roomId, EventType.RoomPinnedEvents, { pinned }, "");
 | 
				
			||||||
                        pinned.splice(index, 1);
 | 
					 | 
				
			||||||
                        await cli.sendStateEvent(room.roomId, EventType.RoomPinnedEvents, { pinned }, "");
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            };
 | 
					            }
 | 
				
			||||||
        }
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // show them in reverse, with latest pinned at the top
 | 
					        // show them in reverse, with latest pinned at the top
 | 
				
			||||||
        content = pinnedEvents.filter(Boolean).reverse().map(ev => (
 | 
					        content = pinnedEvents.filter(Boolean).reverse().map(ev => (
 | 
				
			||||||
            <PinnedEventTile key={ev.getId()} room={room} event={ev} onUnpinClicked={() => onUnpinClicked(ev)} />
 | 
					            <PinnedEventTile
 | 
				
			||||||
 | 
					                key={ev.getId()}
 | 
				
			||||||
 | 
					                room={room}
 | 
				
			||||||
 | 
					                event={ev}
 | 
				
			||||||
 | 
					                onUnpinClicked={canUnpin ? () => onUnpinClicked(ev) : undefined}
 | 
				
			||||||
 | 
					            />
 | 
				
			||||||
        ));
 | 
					        ));
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        content = <div className="mx_PinnedMessagesCard_empty">
 | 
					        content = <div className="mx_PinnedMessagesCard_empty">
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user