@@ -7,85 +7,89 @@ import { selectRoom, selectRoomMode, selectTab } from '@src/client/action/naviga
7
7
function MutualServerTitle ( { userId, roomId } ) {
8
8
const { userList } = initMatrix ;
9
9
const userData = userList . getUserRooms ( userId ) ;
10
- return < > { `${ String ( userData . rooms . length + userData . spaces . length ) } Mutual Servers` } </ > ;
10
+ return (
11
+ < > { `${ String ( userData ? userData . rooms . length + userData . spaces . length : '0' ) } Mutual Servers` } </ >
12
+ ) ;
11
13
}
12
14
13
15
function MutualServerRender ( { userId, requestClose } ) {
14
16
const { userList, mxcUrl } = initMatrix ;
15
17
const mx = initMatrix . matrixClient ;
16
18
17
19
const userData = userList . getUserRooms ( userId ) ;
18
- const total = userData . rooms . length + userData . spaces . length > 0 ;
19
- const openItem = ( roomId , type ) => {
20
- if ( type === 'space' ) selectTab ( roomId , true ) ;
21
- else {
22
- selectRoomMode ( 'room' ) ;
23
- selectRoom ( roomId ) ;
24
- }
25
- requestClose ( ) ;
26
- } ;
20
+ if ( userData ) {
21
+ const total = userData . rooms . length + userData . spaces . length > 0 ;
22
+ const openItem = ( roomId , type ) => {
23
+ if ( type === 'space' ) selectTab ( roomId , true ) ;
24
+ else {
25
+ selectRoomMode ( 'room' ) ;
26
+ selectRoom ( roomId ) ;
27
+ }
28
+ requestClose ( ) ;
29
+ } ;
27
30
28
- if ( total > 0 ) {
29
- return (
30
- < >
31
- { userData . spaces . length > 0 ? (
32
- < >
33
- < div className = "small text-gray ms-2 mb-1" > Spaces</ div >
34
- < ul class = "mutual-servers m-0 p-0" >
35
- { userData . spaces . map ( ( roomId ) => {
36
- const room = mx . getRoom ( roomId ) ;
31
+ if ( total > 0 ) {
32
+ return (
33
+ < >
34
+ { userData . spaces . length > 0 ? (
35
+ < >
36
+ < div className = "small text-gray ms-2 mb-1" > Spaces</ div >
37
+ < ul class = "mutual-servers m-0 p-0" >
38
+ { userData . spaces . map ( ( roomId ) => {
39
+ const room = mx . getRoom ( roomId ) ;
37
40
38
- return (
39
- < li class = "list-group-item" >
40
- < RoomSelector
41
- key = { `mutual_servers_${ roomId } ` }
42
- name = { room . name }
43
- roomId = { roomId }
44
- animParentsCount = { 2 }
45
- imageSrc = { mxcUrl . getAvatarUrl ( room , dfAvatarSize , dfAvatarSize ) }
46
- imageAnimSrc = { mxcUrl . getAvatarUrl ( room ) }
47
- isUnread = { false }
48
- notificationCount = { 0 }
49
- isAlert = { false }
50
- onClick = { ( ) => openItem ( roomId , 'space' ) }
51
- />
52
- </ li >
53
- ) ;
54
- } ) }
55
- </ ul >
56
- </ >
57
- ) : null }
41
+ return (
42
+ < li class = "list-group-item" >
43
+ < RoomSelector
44
+ key = { `mutual_servers_${ roomId } ` }
45
+ name = { room . name }
46
+ roomId = { roomId }
47
+ animParentsCount = { 2 }
48
+ imageSrc = { mxcUrl . getAvatarUrl ( room , dfAvatarSize , dfAvatarSize ) }
49
+ imageAnimSrc = { mxcUrl . getAvatarUrl ( room ) }
50
+ isUnread = { false }
51
+ notificationCount = { 0 }
52
+ isAlert = { false }
53
+ onClick = { ( ) => openItem ( roomId , 'space' ) }
54
+ />
55
+ </ li >
56
+ ) ;
57
+ } ) }
58
+ </ ul >
59
+ </ >
60
+ ) : null }
58
61
59
- { userData . rooms . length > 0 ? (
60
- < >
61
- { userData . spaces . length > 0 ? < hr className = "mx-0 my-2 border-bg" /> : null }
62
- < div className = "small text-gray ms-2 mb-1" > Rooms</ div >
63
- < ul class = "mutual-servers m-0 p-0" >
64
- { userData . rooms . map ( ( roomId ) => {
65
- const room = mx . getRoom ( roomId ) ;
62
+ { userData . rooms . length > 0 ? (
63
+ < >
64
+ { userData . spaces . length > 0 ? < hr className = "mx-0 my-2 border-bg" /> : null }
65
+ < div className = "small text-gray ms-2 mb-1" > Rooms</ div >
66
+ < ul class = "mutual-servers m-0 p-0" >
67
+ { userData . rooms . map ( ( roomId ) => {
68
+ const room = mx . getRoom ( roomId ) ;
66
69
67
- return (
68
- < li class = "list-group-item" >
69
- < RoomSelector
70
- key = { `mutual_servers_${ roomId } ` }
71
- name = { room . name }
72
- roomId = { roomId }
73
- animParentsCount = { 2 }
74
- imageSrc = { mxcUrl . getAvatarUrl ( room , dfAvatarSize , dfAvatarSize ) }
75
- imageAnimSrc = { mxcUrl . getAvatarUrl ( room ) }
76
- isUnread = { false }
77
- notificationCount = { 0 }
78
- isAlert = { false }
79
- onClick = { ( ) => openItem ( roomId , 'room' ) }
80
- />
81
- </ li >
82
- ) ;
83
- } ) }
84
- </ ul >
85
- </ >
86
- ) : null }
87
- </ >
88
- ) ;
70
+ return (
71
+ < li class = "list-group-item" >
72
+ < RoomSelector
73
+ key = { `mutual_servers_${ roomId } ` }
74
+ name = { room . name }
75
+ roomId = { roomId }
76
+ animParentsCount = { 2 }
77
+ imageSrc = { mxcUrl . getAvatarUrl ( room , dfAvatarSize , dfAvatarSize ) }
78
+ imageAnimSrc = { mxcUrl . getAvatarUrl ( room ) }
79
+ isUnread = { false }
80
+ notificationCount = { 0 }
81
+ isAlert = { false }
82
+ onClick = { ( ) => openItem ( roomId , 'room' ) }
83
+ />
84
+ </ li >
85
+ ) ;
86
+ } ) }
87
+ </ ul >
88
+ </ >
89
+ ) : null }
90
+ </ >
91
+ ) ;
92
+ }
89
93
}
90
94
91
95
return < center className = "small" > No room was found.</ center > ;
@@ -94,7 +98,7 @@ function MutualServerRender({ userId, requestClose }) {
94
98
export default function MutualServersTab ( menuBarItems , accountContent , existEthereum , userId ) {
95
99
const { userList } = initMatrix ;
96
100
const userData = userList . getUserRooms ( userId ) ;
97
- if ( userData . rooms . length + userData . spaces . length > 0 )
101
+ if ( userData && userData . rooms . length + userData . spaces . length > 0 )
98
102
menuBarItems . push ( {
99
103
menu : ( { roomId, userId } ) => < MutualServerTitle roomId = { roomId } userId = { userId } /> ,
100
104
render : ( { userId, closeDialog } ) => (
0 commit comments