@@ -35,12 +35,13 @@ const PowerLabel: Record<PowerStatus, TranslationKey> = {
35
35
[ PowerStatus . Moderator ] : _td ( "power_level|mod" ) ,
36
36
} ;
37
37
38
- export type PresenceState = "offline" | "online" | "unavailable" ;
38
+ export type PresenceState = "offline" | "online" | "unavailable" | "io.element.unreachable" ;
39
39
40
40
const PRESENCE_CLASS : Record < PresenceState , string > = {
41
- offline : "mx_EntityTile_offline" ,
42
- online : "mx_EntityTile_online" ,
43
- unavailable : "mx_EntityTile_unavailable" ,
41
+ "offline" : "mx_EntityTile_offline" ,
42
+ "online" : "mx_EntityTile_online" ,
43
+ "unavailable" : "mx_EntityTile_unavailable" ,
44
+ "io.element.unreachable" : "mx_EntityTile_unreachable" ,
44
45
} ;
45
46
46
47
function presenceClassForMember ( presenceState ?: PresenceState , lastActiveAgo ?: number , showPresence ?: boolean ) : string {
@@ -75,7 +76,6 @@ interface IProps {
75
76
presenceCurrentlyActive ?: boolean ;
76
77
showInviteButton : boolean ;
77
78
onClick ( ) : void ;
78
- suppressOnHover : boolean ;
79
79
showPresence : boolean ;
80
80
subtextLabel ?: string ;
81
81
e2eStatus ?: E2EState ;
@@ -93,7 +93,6 @@ export default class EntityTile extends React.PureComponent<IProps, IState> {
93
93
presenceLastActiveAgo : 0 ,
94
94
presenceLastTs : 0 ,
95
95
showInviteButton : false ,
96
- suppressOnHover : false ,
97
96
showPresence : true ,
98
97
} ;
99
98
@@ -105,10 +104,27 @@ export default class EntityTile extends React.PureComponent<IProps, IState> {
105
104
} ;
106
105
}
107
106
107
+ /**
108
+ * Creates the PresenceLabel component if needed
109
+ * @returns The PresenceLabel component if we need to render it, undefined otherwise
110
+ */
111
+ private getPresenceLabel ( ) : JSX . Element | undefined {
112
+ if ( ! this . props . showPresence ) return ;
113
+ const activeAgo = this . props . presenceLastActiveAgo
114
+ ? Date . now ( ) - ( this . props . presenceLastTs - this . props . presenceLastActiveAgo )
115
+ : - 1 ;
116
+ return (
117
+ < PresenceLabel
118
+ activeAgo = { activeAgo }
119
+ currentlyActive = { this . props . presenceCurrentlyActive }
120
+ presenceState = { this . props . presenceState }
121
+ />
122
+ ) ;
123
+ }
124
+
108
125
public render ( ) : React . ReactNode {
109
126
const mainClassNames : Record < string , boolean > = {
110
127
mx_EntityTile : true ,
111
- mx_EntityTile_noHover : ! ! this . props . suppressOnHover ,
112
128
} ;
113
129
if ( this . props . className ) mainClassNames [ this . props . className ] = true ;
114
130
@@ -119,43 +135,13 @@ export default class EntityTile extends React.PureComponent<IProps, IState> {
119
135
) ;
120
136
mainClassNames [ presenceClass ] = true ;
121
137
122
- let nameEl ;
123
138
const name = this . props . nameJSX || this . props . name ;
124
-
125
- if ( ! this . props . suppressOnHover ) {
126
- const activeAgo = this . props . presenceLastActiveAgo
127
- ? Date . now ( ) - ( this . props . presenceLastTs - this . props . presenceLastActiveAgo )
128
- : - 1 ;
129
-
130
- let presenceLabel : JSX . Element | undefined ;
131
- if ( this . props . showPresence ) {
132
- presenceLabel = (
133
- < PresenceLabel
134
- activeAgo = { activeAgo }
135
- currentlyActive = { this . props . presenceCurrentlyActive }
136
- presenceState = { this . props . presenceState }
137
- />
138
- ) ;
139
- }
140
- if ( this . props . subtextLabel ) {
141
- presenceLabel = < span className = "mx_EntityTile_subtext" > { this . props . subtextLabel } </ span > ;
142
- }
143
- nameEl = (
144
- < div className = "mx_EntityTile_details" >
145
- < div className = "mx_EntityTile_name" > { name } </ div >
146
- { presenceLabel }
147
- </ div >
148
- ) ;
149
- } else if ( this . props . subtextLabel ) {
150
- nameEl = (
151
- < div className = "mx_EntityTile_details" >
152
- < div className = "mx_EntityTile_name" > { name } </ div >
153
- < span className = "mx_EntityTile_subtext" > { this . props . subtextLabel } </ span >
154
- </ div >
155
- ) ;
156
- } else {
157
- nameEl = < div className = "mx_EntityTile_name" > { name } </ div > ;
158
- }
139
+ const nameAndPresence = (
140
+ < div className = "mx_EntityTile_details" >
141
+ < div className = "mx_EntityTile_name" > { name } </ div >
142
+ { this . getPresenceLabel ( ) }
143
+ </ div >
144
+ ) ;
159
145
160
146
let inviteButton ;
161
147
if ( this . props . showInviteButton ) {
@@ -198,7 +184,7 @@ export default class EntityTile extends React.PureComponent<IProps, IState> {
198
184
{ av }
199
185
{ e2eIcon }
200
186
</ div >
201
- { nameEl }
187
+ { nameAndPresence }
202
188
{ powerLabel }
203
189
{ inviteButton }
204
190
</ AccessibleButton >
0 commit comments