mirror of https://github.com/vector-im/riot-web
Merge pull request #5881 from matrix-org/t3chguy/fix/16704
Clean up add existing to space dialog and include DMs in it toopull/21833/head
commit
12d96fe096
|
@ -57,21 +57,22 @@ const AddExistingToSpaceDialog: React.FC<IProps> = ({ matrixClient: cli, space,
|
||||||
|
|
||||||
const existingSubspaces = SpaceStore.instance.getChildSpaces(space.roomId);
|
const existingSubspaces = SpaceStore.instance.getChildSpaces(space.roomId);
|
||||||
const existingSubspacesSet = new Set(existingSubspaces);
|
const existingSubspacesSet = new Set(existingSubspaces);
|
||||||
const spaces = SpaceStore.instance.getSpaces().filter(s => {
|
const existingRoomsSet = new Set(SpaceStore.instance.getChildRooms(space.roomId));
|
||||||
return !existingSubspacesSet.has(s) // not already in space
|
|
||||||
&& space !== s // not the top-level space
|
|
||||||
&& selectedSpace !== s // not the selected space
|
|
||||||
&& s.name.toLowerCase().includes(lcQuery); // contains query
|
|
||||||
});
|
|
||||||
|
|
||||||
const existingRooms = SpaceStore.instance.getChildRooms(space.roomId);
|
const [spaces, rooms, dms] = cli.getVisibleRooms().reduce((arr, room) => {
|
||||||
const existingRoomsSet = new Set(existingRooms);
|
if (room.getMyMembership() !== "join") return arr;
|
||||||
const rooms = cli.getVisibleRooms().filter(room => {
|
if (!room.name.toLowerCase().includes(lcQuery)) return arr;
|
||||||
return !existingRoomsSet.has(room) // not already in space
|
|
||||||
&& !room.isSpaceRoom() // not a space itself
|
if (room.isSpaceRoom()) {
|
||||||
&& room.name.toLowerCase().includes(lcQuery) // contains query
|
if (room !== space && room !== selectedSpace && !existingSubspacesSet.has(room)) {
|
||||||
&& !DMRoomMap.shared().getUserIdForRoomId(room.roomId); // not a DM
|
arr[0].push(room);
|
||||||
});
|
}
|
||||||
|
} else if (!existingRoomsSet.has(room) && selectedSpace.joinRule() !== "public") {
|
||||||
|
// Only show DMs for non-public spaces as they make very little sense in spaces other than "Just Me" ones.
|
||||||
|
arr[DMRoomMap.shared().getUserIdForRoomId(room.roomId) ? 2 : 1].push(room);
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}, [[], [], []]);
|
||||||
|
|
||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
@ -172,7 +173,28 @@ const AddExistingToSpaceDialog: React.FC<IProps> = ({ matrixClient: cli, space,
|
||||||
</div>
|
</div>
|
||||||
) : null }
|
) : null }
|
||||||
|
|
||||||
{ spaces.length + rooms.length < 1 ? <span className="mx_AddExistingToSpaceDialog_noResults">
|
{ dms.length > 0 ? (
|
||||||
|
<div className="mx_AddExistingToSpaceDialog_section">
|
||||||
|
<h3>{ _t("Direct Messages") }</h3>
|
||||||
|
{ dms.map(space => {
|
||||||
|
return <Entry
|
||||||
|
key={space.roomId}
|
||||||
|
room={space}
|
||||||
|
checked={selectedToAdd.has(space)}
|
||||||
|
onChange={(checked) => {
|
||||||
|
if (checked) {
|
||||||
|
selectedToAdd.add(space);
|
||||||
|
} else {
|
||||||
|
selectedToAdd.delete(space);
|
||||||
|
}
|
||||||
|
setSelectedToAdd(new Set(selectedToAdd));
|
||||||
|
}}
|
||||||
|
/>;
|
||||||
|
}) }
|
||||||
|
</div>
|
||||||
|
) : null }
|
||||||
|
|
||||||
|
{ spaces.length + rooms.length + dms.length < 1 ? <span className="mx_AddExistingToSpaceDialog_noResults">
|
||||||
{ _t("No results") }
|
{ _t("No results") }
|
||||||
</span> : undefined }
|
</span> : undefined }
|
||||||
</AutoHideScrollbar>
|
</AutoHideScrollbar>
|
||||||
|
|
|
@ -2013,6 +2013,7 @@
|
||||||
"Add existing rooms": "Add existing rooms",
|
"Add existing rooms": "Add existing rooms",
|
||||||
"Filter your rooms and spaces": "Filter your rooms and spaces",
|
"Filter your rooms and spaces": "Filter your rooms and spaces",
|
||||||
"Spaces": "Spaces",
|
"Spaces": "Spaces",
|
||||||
|
"Direct Messages": "Direct Messages",
|
||||||
"Don't want to add an existing room?": "Don't want to add an existing room?",
|
"Don't want to add an existing room?": "Don't want to add an existing room?",
|
||||||
"Create a new room": "Create a new room",
|
"Create a new room": "Create a new room",
|
||||||
"Failed to add rooms to space": "Failed to add rooms to space",
|
"Failed to add rooms to space": "Failed to add rooms to space",
|
||||||
|
@ -2203,7 +2204,6 @@
|
||||||
"Suggestions": "Suggestions",
|
"Suggestions": "Suggestions",
|
||||||
"May include members not in %(communityName)s": "May include members not in %(communityName)s",
|
"May include members not in %(communityName)s": "May include members not in %(communityName)s",
|
||||||
"Recently Direct Messaged": "Recently Direct Messaged",
|
"Recently Direct Messaged": "Recently Direct Messaged",
|
||||||
"Direct Messages": "Direct Messages",
|
|
||||||
"Start a conversation with someone using their name, email address or username (like <userId/>).": "Start a conversation with someone using their name, email address or username (like <userId/>).",
|
"Start a conversation with someone using their name, email address or username (like <userId/>).": "Start a conversation with someone using their name, email address or username (like <userId/>).",
|
||||||
"Start a conversation with someone using their name or username (like <userId/>).": "Start a conversation with someone using their name or username (like <userId/>).",
|
"Start a conversation with someone using their name or username (like <userId/>).": "Start a conversation with someone using their name or username (like <userId/>).",
|
||||||
"This won't invite them to %(communityName)s. To invite someone to %(communityName)s, click <a>here</a>": "This won't invite them to %(communityName)s. To invite someone to %(communityName)s, click <a>here</a>",
|
"This won't invite them to %(communityName)s. To invite someone to %(communityName)s, click <a>here</a>": "This won't invite them to %(communityName)s. To invite someone to %(communityName)s, click <a>here</a>",
|
||||||
|
|
Loading…
Reference in New Issue