You've already forked matrix-react-sdk
							
							
				mirror of
				https://github.com/matrix-org/matrix-react-sdk.git
				synced 2025-11-03 00:33:22 +03:00 
			
		
		
		
	Fix Manage Restricted Join Rule Dialog for Spaces (#7208)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							9fefeefc8c
						
					
				
				
					commit
					35d4ec6e80
				
			@@ -66,6 +66,17 @@ const Entry = ({ room, checked, onChange }) => {
 | 
				
			|||||||
    </label>;
 | 
					    </label>;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const addAllParents = (set: Set<Room>, room: Room): void => {
 | 
				
			||||||
 | 
					    const cli = room.client;
 | 
				
			||||||
 | 
					    const parents = Array.from(SpaceStore.instance.getKnownParents(room.roomId)).map(parentId => cli.getRoom(parentId));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    parents.forEach(parent => {
 | 
				
			||||||
 | 
					        if (set.has(parent)) return;
 | 
				
			||||||
 | 
					        set.add(parent);
 | 
				
			||||||
 | 
					        addAllParents(set, parent);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [], onFinished }) => {
 | 
					const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [], onFinished }) => {
 | 
				
			||||||
    const cli = room.client;
 | 
					    const cli = room.client;
 | 
				
			||||||
    const [newSelected, setNewSelected] = useState(new Set<string>(selected));
 | 
					    const [newSelected, setNewSelected] = useState(new Set<string>(selected));
 | 
				
			||||||
@@ -73,9 +84,10 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
 | 
				
			|||||||
    const lcQuery = query.toLowerCase().trim();
 | 
					    const lcQuery = query.toLowerCase().trim();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const [spacesContainingRoom, otherEntries] = useMemo(() => {
 | 
					    const [spacesContainingRoom, otherEntries] = useMemo(() => {
 | 
				
			||||||
        const spaces = cli.getVisibleRooms().filter(r => r.getMyMembership() === "join" && r.isSpaceRoom());
 | 
					        const parents = new Set<Room>();
 | 
				
			||||||
 | 
					        addAllParents(parents, room);
 | 
				
			||||||
        return [
 | 
					        return [
 | 
				
			||||||
            spaces.filter(r => SpaceStore.instance.getSpaceFilteredRoomIds(r.roomId).has(room.roomId)),
 | 
					            Array.from(parents),
 | 
				
			||||||
            selected.map(roomId => {
 | 
					            selected.map(roomId => {
 | 
				
			||||||
                const room = cli.getRoom(roomId);
 | 
					                const room = cli.getRoom(roomId);
 | 
				
			||||||
                if (!room) {
 | 
					                if (!room) {
 | 
				
			||||||
@@ -86,9 +98,9 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }).filter(Boolean),
 | 
					            }).filter(Boolean),
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
    }, [cli, selected, room.roomId]);
 | 
					    }, [cli, selected, room]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const [filteredSpacesContainingRooms, filteredOtherEntries] = useMemo(() => [
 | 
					    const [filteredSpacesContainingRoom, filteredOtherEntries] = useMemo(() => [
 | 
				
			||||||
        spacesContainingRoom.filter(r => r.name.toLowerCase().includes(lcQuery)),
 | 
					        spacesContainingRoom.filter(r => r.name.toLowerCase().includes(lcQuery)),
 | 
				
			||||||
        otherEntries.filter(r => r.name.toLowerCase().includes(lcQuery)),
 | 
					        otherEntries.filter(r => r.name.toLowerCase().includes(lcQuery)),
 | 
				
			||||||
    ], [spacesContainingRoom, otherEntries, lcQuery]);
 | 
					    ], [spacesContainingRoom, otherEntries, lcQuery]);
 | 
				
			||||||
@@ -129,10 +141,14 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
 | 
				
			|||||||
                autoFocus={true}
 | 
					                autoFocus={true}
 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
            <AutoHideScrollbar className="mx_ManageRestrictedJoinRuleDialog_content">
 | 
					            <AutoHideScrollbar className="mx_ManageRestrictedJoinRuleDialog_content">
 | 
				
			||||||
                { filteredSpacesContainingRooms.length > 0 ? (
 | 
					                { filteredSpacesContainingRoom.length > 0 ? (
 | 
				
			||||||
                    <div className="mx_ManageRestrictedJoinRuleDialog_section">
 | 
					                    <div className="mx_ManageRestrictedJoinRuleDialog_section">
 | 
				
			||||||
                        <h3>{ _t("Spaces you know that contain this room") }</h3>
 | 
					                        <h3>
 | 
				
			||||||
                        { filteredSpacesContainingRooms.map(space => {
 | 
					                            { room.isSpaceRoom()
 | 
				
			||||||
 | 
					                                ? _t("Spaces you know that contain this space")
 | 
				
			||||||
 | 
					                                : _t("Spaces you know that contain this room") }
 | 
				
			||||||
 | 
					                        </h3>
 | 
				
			||||||
 | 
					                        { filteredSpacesContainingRoom.map(space => {
 | 
				
			||||||
                            return <Entry
 | 
					                            return <Entry
 | 
				
			||||||
                                key={space.roomId}
 | 
					                                key={space.roomId}
 | 
				
			||||||
                                room={space}
 | 
					                                room={space}
 | 
				
			||||||
@@ -164,7 +180,7 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
 | 
				
			|||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                ) : null }
 | 
					                ) : null }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                { filteredSpacesContainingRooms.length + filteredOtherEntries.length < 1
 | 
					                { filteredSpacesContainingRoom.length + filteredOtherEntries.length < 1
 | 
				
			||||||
                    ? <span className="mx_ManageRestrictedJoinRuleDialog_noResults">
 | 
					                    ? <span className="mx_ManageRestrictedJoinRuleDialog_noResults">
 | 
				
			||||||
                        { _t("No results") }
 | 
					                        { _t("No results") }
 | 
				
			||||||
                    </span>
 | 
					                    </span>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2570,6 +2570,7 @@
 | 
				
			|||||||
    "Select spaces": "Select spaces",
 | 
					    "Select spaces": "Select spaces",
 | 
				
			||||||
    "Decide which spaces can access this room. If a space is selected, its members can find and join <RoomName/>.": "Decide which spaces can access this room. If a space is selected, its members can find and join <RoomName/>.",
 | 
					    "Decide which spaces can access this room. If a space is selected, its members can find and join <RoomName/>.": "Decide which spaces can access this room. If a space is selected, its members can find and join <RoomName/>.",
 | 
				
			||||||
    "Search spaces": "Search spaces",
 | 
					    "Search spaces": "Search spaces",
 | 
				
			||||||
 | 
					    "Spaces you know that contain this space": "Spaces you know that contain this space",
 | 
				
			||||||
    "Spaces you know that contain this room": "Spaces you know that contain this room",
 | 
					    "Spaces you know that contain this room": "Spaces you know that contain this room",
 | 
				
			||||||
    "Other spaces or rooms you might not know": "Other spaces or rooms you might not know",
 | 
					    "Other spaces or rooms you might not know": "Other spaces or rooms you might not know",
 | 
				
			||||||
    "These are likely ones other room admins are a part of.": "These are likely ones other room admins are a part of.",
 | 
					    "These are likely ones other room admins are a part of.": "These are likely ones other room admins are a part of.",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user