Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 6ab255a

Browse files
committed
Support adding space-restricted joins on rooms not members of those spaces
1 parent bd89498 commit 6ab255a

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/components/views/dialogs/ManageRestrictedJoinRuleDialog.tsx

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,20 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
8383
const [query, setQuery] = useState("");
8484
const lcQuery = query.toLowerCase().trim();
8585

86-
const [spacesContainingRoom, otherEntries] = useMemo(() => {
86+
const [spacesContainingRoom, otherJoinedSpaces, otherEntries] = useMemo(() => {
8787
const parents = new Set<Room>();
88+
89+
// Add the known parents first so the user can see them more easily
8890
addAllParents(parents, room);
91+
92+
// Add all the other known spaces second. We cheat and rely on the Set not
93+
// allowing duplicates here, which should maintain our insertion order from
94+
// above.
95+
// SpaceStore.instance.spacePanelSpaces.forEach(s => parents.add(s));
96+
8997
return [
9098
Array.from(parents),
99+
SpaceStore.instance.spacePanelSpaces.filter(s => !parents.has(s)),
91100
selected.map(roomId => {
92101
const room = cli.getRoom(roomId);
93102
if (!room) {
@@ -100,8 +109,9 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
100109
];
101110
}, [cli, selected, room]);
102111

103-
const [filteredSpacesContainingRoom, filteredOtherEntries] = useMemo(() => [
112+
const [filteredSpacesContainingRoom, filteredOtherJoinedSpaces, filteredOtherEntries] = useMemo(() => [
104113
spacesContainingRoom.filter(r => r.name.toLowerCase().includes(lcQuery)),
114+
otherJoinedSpaces.filter(r => r.name.toLowerCase().includes(lcQuery)),
105115
otherEntries.filter(r => r.name.toLowerCase().includes(lcQuery)),
106116
], [spacesContainingRoom, otherEntries, lcQuery]);
107117

@@ -121,6 +131,10 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
121131
</div>;
122132
}
123133

134+
const totalResults =
135+
filteredSpacesContainingRoom.length
136+
+ filteredOtherJoinedSpaces.length
137+
+ filteredOtherEntries.length;
124138
return <BaseDialog
125139
title={_t("Select spaces")}
126140
className="mx_ManageRestrictedJoinRuleDialog"
@@ -180,7 +194,23 @@ const ManageRestrictedJoinRuleDialog: React.FC<IProps> = ({ room, selected = [],
180194
</div>
181195
) : null }
182196

183-
{ filteredSpacesContainingRoom.length + filteredOtherEntries.length < 1
197+
{ filteredOtherJoinedSpaces.length > 0 ? (
198+
<div className="mx_ManageRestrictedJoinRuleDialog_section">
199+
<h3>{ _t("Other spaces you know") }</h3>
200+
{ filteredOtherJoinedSpaces.map(space => {
201+
return <Entry
202+
key={space.roomId}
203+
room={space}
204+
checked={newSelected.has(space.roomId)}
205+
onChange={(checked: boolean) => {
206+
onChange(checked, space);
207+
}}
208+
/>;
209+
}) }
210+
</div>
211+
) : null }
212+
213+
{ totalResults < 1
184214
? <span className="mx_ManageRestrictedJoinRuleDialog_noResults">
185215
{ _t("No results") }
186216
</span>

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,6 +2646,7 @@
26462646
"Spaces you know that contain this room": "Spaces you know that contain this room",
26472647
"Other spaces or rooms you might not know": "Other spaces or rooms you might not know",
26482648
"These are likely ones other room admins are a part of.": "These are likely ones other room admins are a part of.",
2649+
"Other spaces you know": "Other spaces you know",
26492650
"Confirm by comparing the following with the User Settings in your other session:": "Confirm by comparing the following with the User Settings in your other session:",
26502651
"Confirm this user's session by comparing the following with their User Settings:": "Confirm this user's session by comparing the following with their User Settings:",
26512652
"Session name": "Session name",

0 commit comments

Comments
 (0)