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

Commit 13a5d06

Browse files
authored
Merge pull request #5926 from matrix-org/t3chguy/fix/17067
Fix issues with space hierarchy in layout and with incompatible servers
2 parents 31b9a4c + 43b43dc commit 13a5d06

File tree

3 files changed

+64
-61
lines changed

3 files changed

+64
-61
lines changed

res/css/structures/_SpaceRoomDirectory.scss

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ limitations under the License.
2626
word-break: break-word;
2727
display: flex;
2828
flex-direction: column;
29+
}
2930

31+
.mx_SpaceRoomDirectory,
32+
.mx_SpaceRoomView_landing {
3033
.mx_Dialog_title {
3134
display: flex;
3235

@@ -56,65 +59,63 @@ limitations under the License.
5659
}
5760
}
5861

59-
.mx_Dialog_content {
60-
.mx_AccessibleButton_kind_link {
61-
padding: 0;
62-
}
63-
64-
.mx_SearchBox {
65-
margin: 24px 0 16px;
66-
}
62+
.mx_AccessibleButton_kind_link {
63+
padding: 0;
64+
}
6765

68-
.mx_SpaceRoomDirectory_noResults {
69-
text-align: center;
66+
.mx_SearchBox {
67+
margin: 24px 0 16px;
68+
}
7069

71-
> div {
72-
font-size: $font-15px;
73-
line-height: $font-24px;
74-
color: $secondary-fg-color;
75-
}
76-
}
70+
.mx_SpaceRoomDirectory_noResults {
71+
text-align: center;
7772

78-
.mx_SpaceRoomDirectory_listHeader {
79-
display: flex;
80-
min-height: 32px;
81-
align-items: center;
73+
> div {
8274
font-size: $font-15px;
8375
line-height: $font-24px;
84-
color: $primary-fg-color;
76+
color: $secondary-fg-color;
77+
}
78+
}
8579

86-
.mx_AccessibleButton {
87-
padding: 2px 8px;
88-
font-weight: normal;
80+
.mx_SpaceRoomDirectory_listHeader {
81+
display: flex;
82+
min-height: 32px;
83+
align-items: center;
84+
font-size: $font-15px;
85+
line-height: $font-24px;
86+
color: $primary-fg-color;
8987

90-
& + .mx_AccessibleButton {
91-
margin-left: 16px;
92-
}
93-
}
88+
.mx_AccessibleButton {
89+
padding: 2px 8px;
90+
font-weight: normal;
9491

95-
> span {
96-
margin-left: auto;
92+
& + .mx_AccessibleButton {
93+
margin-left: 16px;
9794
}
9895
}
9996

100-
.mx_SpaceRoomDirectory_error {
101-
position: relative;
102-
font-weight: $font-semi-bold;
103-
color: $notice-primary-color;
104-
font-size: $font-15px;
105-
line-height: $font-18px;
106-
margin: 20px auto 12px;
107-
padding-left: 24px;
108-
width: max-content;
109-
110-
&::before {
111-
content: "";
112-
position: absolute;
113-
height: 16px;
114-
width: 16px;
115-
left: 0;
116-
background-image: url("$(res)/img/element-icons/warning-badge.svg");
117-
}
97+
> span {
98+
margin-left: auto;
99+
}
100+
}
101+
102+
.mx_SpaceRoomDirectory_error {
103+
position: relative;
104+
font-weight: $font-semi-bold;
105+
color: $notice-primary-color;
106+
font-size: $font-15px;
107+
line-height: $font-18px;
108+
margin: 20px auto 12px;
109+
padding-left: 24px;
110+
width: max-content;
111+
112+
&::before {
113+
content: "";
114+
position: absolute;
115+
height: 16px;
116+
width: 16px;
117+
left: 0;
118+
background-image: url("$(res)/img/element-icons/warning-badge.svg");
118119
}
119120
}
120121
}

src/components/structures/SpaceRoomDirectory.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,12 @@ export const HierarchyLevel = ({
312312

313313
// mutate argument refreshToken to force a reload
314314
export const useSpaceSummary = (cli: MatrixClient, space: Room, refreshToken?: any): [
315+
null,
315316
ISpaceSummaryRoom[],
316-
Map<string, Map<string, ISpaceSummaryEvent>>,
317-
Map<string, Set<string>>,
318-
Map<string, Set<string>>,
319-
] | [] => {
317+
Map<string, Map<string, ISpaceSummaryEvent>>?,
318+
Map<string, Set<string>>?,
319+
Map<string, Set<string>>?,
320+
] | [Error] => {
320321
// TODO pagination
321322
return useAsyncMemo(async () => {
322323
try {
@@ -336,13 +337,12 @@ export const useSpaceSummary = (cli: MatrixClient, space: Room, refreshToken?: a
336337
}
337338
});
338339

339-
return [data.rooms as ISpaceSummaryRoom[], parentChildRelations, viaMap, childParentRelations];
340+
return [null, data.rooms as ISpaceSummaryRoom[], parentChildRelations, viaMap, childParentRelations];
340341
} catch (e) {
341342
console.error(e); // TODO
343+
return [e];
342344
}
343-
344-
return [];
345-
}, [space, refreshToken], []);
345+
}, [space, refreshToken], [undefined]);
346346
};
347347

348348
export const SpaceHierarchy: React.FC<IHierarchyProps> = ({
@@ -358,7 +358,7 @@ export const SpaceHierarchy: React.FC<IHierarchyProps> = ({
358358

359359
const [selected, setSelected] = useState(new Map<string, Set<string>>()); // Map<parentId, Set<childId>>
360360

361-
const [rooms, parentChildMap, viaMap, childParentMap] = useSpaceSummary(cli, space, refreshToken);
361+
const [summaryError, rooms, parentChildMap, viaMap, childParentMap] = useSpaceSummary(cli, space, refreshToken);
362362

363363
const roomsMap = useMemo(() => {
364364
if (!rooms) return null;
@@ -397,6 +397,10 @@ export const SpaceHierarchy: React.FC<IHierarchyProps> = ({
397397
const [removing, setRemoving] = useState(false);
398398
const [saving, setSaving] = useState(false);
399399

400+
if (summaryError) {
401+
return <p>{_t("Your server does not support showing space hierarchies.")}</p>;
402+
}
403+
400404
let content;
401405
if (roomsMap) {
402406
const numRooms = Array.from(roomsMap.values()).filter(r => r.room_type !== RoomType.Space).length;
@@ -538,10 +542,8 @@ export const SpaceHierarchy: React.FC<IHierarchyProps> = ({
538542
{ children }
539543
</AutoHideScrollbar>
540544
</>;
541-
} else if (!rooms) {
542-
content = <Spinner />;
543545
} else {
544-
content = <p>{_t("Your server does not support showing space hierarchies.")}</p>;
546+
content = <Spinner />;
545547
}
546548

547549
// TODO loading state/error state

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2638,6 +2638,7 @@
26382638
"%(count)s rooms|one": "%(count)s room",
26392639
"This room is suggested as a good one to join": "This room is suggested as a good one to join",
26402640
"Suggested": "Suggested",
2641+
"Your server does not support showing space hierarchies.": "Your server does not support showing space hierarchies.",
26412642
"%(count)s rooms and %(numSpaces)s spaces|other": "%(count)s rooms and %(numSpaces)s spaces",
26422643
"%(count)s rooms and %(numSpaces)s spaces|one": "%(count)s room and %(numSpaces)s spaces",
26432644
"%(count)s rooms and 1 space|other": "%(count)s rooms and 1 space",
@@ -2648,7 +2649,6 @@
26482649
"Mark as suggested": "Mark as suggested",
26492650
"No results found": "No results found",
26502651
"You may want to try a different search or check for typos.": "You may want to try a different search or check for typos.",
2651-
"Your server does not support showing space hierarchies.": "Your server does not support showing space hierarchies.",
26522652
"Search names and description": "Search names and description",
26532653
"If you can't find the room you're looking for, ask for an invite or <a>create a new room</a>.": "If you can't find the room you're looking for, ask for an invite or <a>create a new room</a>.",
26542654
"Create room": "Create room",

0 commit comments

Comments
 (0)