Improve new search dialog context text for exactly 2 parent spaces (#7761)

pull/21833/head
Michael Telatynski 2022-02-08 19:08:05 +00:00 committed by GitHub
parent f13329213d
commit 919aab053e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View File

@ -161,10 +161,16 @@ function guessDMRoomTargetId(room: Room, myUserId: string): string {
export function spaceContextDetailsText(space: Room): string {
if (!space.isSpaceRoom()) return undefined;
const [parent, ...otherParents] = SpaceStore.instance.getKnownParents(space.roomId);
if (parent) {
const [parent, secondParent, ...otherParents] = SpaceStore.instance.getKnownParents(space.roomId);
if (secondParent && !otherParents?.length) {
// exactly 2 edge case for improved i18n
return _t("%(space1Name)s and %(space2Name)s", {
space1Name: space.client.getRoom(parent)?.name,
space2Name: space.client.getRoom(secondParent)?.name,
});
} else if (parent) {
return _t("%(spaceName)s and %(count)s others", {
spaceName: space.client.getRoom(parent).name,
spaceName: space.client.getRoom(parent)?.name,
count: otherParents.length,
});
}
@ -180,10 +186,16 @@ export function roomContextDetailsText(room: Room): string {
return dmPartner;
}
const [parent, ...otherParents] = SpaceStore.instance.getKnownParents(room.roomId);
if (parent) {
const [parent, secondParent, ...otherParents] = SpaceStore.instance.getKnownParents(room.roomId);
if (secondParent && !otherParents?.length) {
// exactly 2 edge case for improved i18n
return _t("%(space1Name)s and %(space2Name)s", {
space1Name: room.client.getRoom(parent)?.name,
space2Name: room.client.getRoom(secondParent)?.name,
});
} else if (parent) {
return _t("%(spaceName)s and %(count)s others", {
spaceName: room.client.getRoom(parent).name,
spaceName: room.client.getRoom(parent)?.name,
count: otherParents.length,
});
}

View File

@ -399,6 +399,7 @@
"Failed to invite users to the room:": "Failed to invite users to the room:",
"We sent the others, but the below people couldn't be invited to <RoomName/>": "We sent the others, but the below people couldn't be invited to <RoomName/>",
"Some invites couldn't be sent": "Some invites couldn't be sent",
"%(space1Name)s and %(space2Name)s": "%(space1Name)s and %(space2Name)s",
"%(spaceName)s and %(count)s others|other": "%(spaceName)s and %(count)s others",
"%(spaceName)s and %(count)s others|zero": "%(spaceName)s",
"%(spaceName)s and %(count)s others|one": "%(spaceName)s and %(count)s other",