@@ -14,9 +14,8 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- import React , { createRef , useContext , useRef , useState } from "react" ;
17
+ import React , { createRef } from "react" ;
18
18
import { Room } from "matrix-js-sdk/src/models/room" ;
19
- import classNames from "classnames" ;
20
19
21
20
import { MatrixClientPeg } from "../../MatrixClientPeg" ;
22
21
import defaultDispatcher from "../../dispatcher/dispatcher" ;
@@ -32,9 +31,7 @@ import LogoutDialog from "../views/dialogs/LogoutDialog";
32
31
import SettingsStore from "../../settings/SettingsStore" ;
33
32
import { findHighContrastTheme , getCustomTheme , isHighContrastTheme } from "../../theme" ;
34
33
import {
35
- RovingAccessibleButton ,
36
34
RovingAccessibleTooltipButton ,
37
- useRovingTabIndex ,
38
35
} from "../../accessibility/RovingTabIndex" ;
39
36
import AccessibleButton , { ButtonEvent } from "../views/elements/AccessibleButton" ;
40
37
import SdkConfig from "../../SdkConfig" ;
@@ -44,73 +41,17 @@ import { UPDATE_EVENT } from "../../stores/AsyncStore";
44
41
import BaseAvatar from '../views/avatars/BaseAvatar' ;
45
42
import { SettingLevel } from "../../settings/SettingLevel" ;
46
43
import IconizedContextMenu , {
47
- IconizedContextMenuCheckbox ,
48
44
IconizedContextMenuOption ,
49
45
IconizedContextMenuOptionList ,
50
46
} from "../views/context_menus/IconizedContextMenu" ;
51
47
import { UIFeature } from "../../settings/UIFeature" ;
52
48
import HostSignupAction from "./HostSignupAction" ;
53
49
import SpaceStore from "../../stores/spaces/SpaceStore" ;
54
50
import { UPDATE_SELECTED_SPACE } from "../../stores/spaces" ;
55
- import MatrixClientContext from "../../contexts/MatrixClientContext" ;
56
- import { SettingUpdatedPayload } from "../../dispatcher/payloads/SettingUpdatedPayload" ;
57
51
import UserIdentifierCustomisations from "../../customisations/UserIdentifier" ;
58
52
import PosthogTrackers from "../../PosthogTrackers" ;
59
53
import { ViewHomePagePayload } from "../../dispatcher/payloads/ViewHomePagePayload" ;
60
54
61
- const CustomStatusSection = ( ) => {
62
- const cli = useContext ( MatrixClientContext ) ;
63
- const setStatus = cli . getUser ( cli . getUserId ( ) ) . unstable_statusMessage || "" ;
64
- const [ value , setValue ] = useState ( setStatus ) ;
65
-
66
- const ref = useRef < HTMLInputElement > ( null ) ;
67
- const [ onFocus , isActive ] = useRovingTabIndex ( ref ) ;
68
-
69
- const classes = classNames ( {
70
- 'mx_UserMenu_CustomStatusSection_field' : true ,
71
- 'mx_UserMenu_CustomStatusSection_field_hasQuery' : value ,
72
- } ) ;
73
-
74
- let details : JSX . Element ;
75
- if ( value !== setStatus ) {
76
- details = < >
77
- < p > { _t ( "Your status will be shown to people you have a DM with." ) } </ p >
78
-
79
- < RovingAccessibleButton
80
- onClick = { ( ) => cli . _unstable_setStatusMessage ( value ) }
81
- kind = "primary_outline"
82
- >
83
- { value ? _t ( "Set status" ) : _t ( "Clear status" ) }
84
- </ RovingAccessibleButton >
85
- </ > ;
86
- }
87
-
88
- return < form className = "mx_UserMenu_CustomStatusSection" >
89
- < div className = { classes } >
90
- < input
91
- type = "text"
92
- value = { value }
93
- className = "mx_UserMenu_CustomStatusSection_input"
94
- onChange = { e => setValue ( e . target . value ) }
95
- placeholder = { _t ( "Set a new status" ) }
96
- autoComplete = "off"
97
- onFocus = { onFocus }
98
- ref = { ref }
99
- tabIndex = { isActive ? 0 : - 1 }
100
- />
101
- < AccessibleButton
102
- // The clear button is only for mouse users
103
- tabIndex = { - 1 }
104
- title = { _t ( "Clear" ) }
105
- className = "mx_UserMenu_CustomStatusSection_clear"
106
- onClick = { ( ) => setValue ( "" ) }
107
- />
108
- </ div >
109
-
110
- { details }
111
- </ form > ;
112
- } ;
113
-
114
55
interface IProps {
115
56
isPanelCollapsed : boolean ;
116
57
}
@@ -122,7 +63,6 @@ interface IState {
122
63
isDarkTheme : boolean ;
123
64
isHighContrast : boolean ;
124
65
selectedSpace ?: Room ;
125
- dndEnabled : boolean ;
126
66
}
127
67
128
68
const toRightOf = ( rect : PartialDOMRect ) => {
@@ -154,19 +94,11 @@ export default class UserMenu extends React.Component<IProps, IState> {
154
94
contextMenuPosition : null ,
155
95
isDarkTheme : this . isUserOnDarkTheme ( ) ,
156
96
isHighContrast : this . isUserOnHighContrastTheme ( ) ,
157
- dndEnabled : this . doNotDisturb ,
158
97
selectedSpace : SpaceStore . instance . activeSpaceRoom ,
159
98
} ;
160
99
161
100
OwnProfileStore . instance . on ( UPDATE_EVENT , this . onProfileUpdate ) ;
162
101
SpaceStore . instance . on ( UPDATE_SELECTED_SPACE , this . onSelectedSpaceUpdate ) ;
163
-
164
- SettingsStore . monitorSetting ( "feature_dnd" , null ) ;
165
- SettingsStore . monitorSetting ( "doNotDisturb" , null ) ;
166
- }
167
-
168
- private get doNotDisturb ( ) : boolean {
169
- return SettingsStore . getValue ( "doNotDisturb" ) ;
170
102
}
171
103
172
104
private get hasHomePage ( ) : boolean {
@@ -239,20 +171,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
239
171
if ( this . buttonRef . current ) this . buttonRef . current . click ( ) ;
240
172
}
241
173
break ;
242
-
243
- case Action . SettingUpdated : {
244
- const settingUpdatedPayload = payload as SettingUpdatedPayload ;
245
- switch ( settingUpdatedPayload . settingName ) {
246
- case "feature_dnd" :
247
- case "doNotDisturb" : {
248
- const dndEnabled = this . doNotDisturb ;
249
- if ( this . state . dndEnabled !== dndEnabled ) {
250
- this . setState ( { dndEnabled } ) ;
251
- }
252
- break ;
253
- }
254
- }
255
- }
256
174
}
257
175
} ;
258
176
@@ -348,12 +266,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
348
266
this . setState ( { contextMenuPosition : null } ) ; // also close the menu
349
267
} ;
350
268
351
- private onDndToggle = ( ev : ButtonEvent ) => {
352
- ev . stopPropagation ( ) ;
353
- const current = SettingsStore . getValue ( "doNotDisturb" ) ;
354
- SettingsStore . setValue ( "doNotDisturb" , null , SettingLevel . DEVICE , ! current ) ;
355
- } ;
356
-
357
269
private renderContextMenu = ( ) : React . ReactNode => {
358
270
if ( ! this . state . contextMenuPosition ) return null ;
359
271
@@ -400,24 +312,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
400
312
) ;
401
313
}
402
314
403
- let customStatusSection : JSX . Element ;
404
- if ( SettingsStore . getValue ( "feature_custom_status" ) ) {
405
- customStatusSection = < CustomStatusSection /> ;
406
- }
407
-
408
- let dndButton : JSX . Element ;
409
- if ( SettingsStore . getValue ( "feature_dnd" ) ) {
410
- dndButton = (
411
- < IconizedContextMenuCheckbox
412
- iconClassName = { this . state . dndEnabled ? "mx_UserMenu_iconDnd" : "mx_UserMenu_iconDndOff" }
413
- label = { _t ( "Do not disturb" ) }
414
- onClick = { this . onDndToggle }
415
- active = { this . state . dndEnabled }
416
- words
417
- />
418
- ) ;
419
- }
420
-
421
315
let feedbackButton ;
422
316
if ( SettingsStore . getValue ( UIFeature . Feedback ) ) {
423
317
feedbackButton = < IconizedContextMenuOption
@@ -430,7 +324,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
430
324
let primaryOptionList = (
431
325
< IconizedContextMenuOptionList >
432
326
{ homeButton }
433
- { dndButton }
434
327
< IconizedContextMenuOption
435
328
iconClassName = "mx_UserMenu_iconBell"
436
329
label = { _t ( "Notifications" ) }
@@ -502,7 +395,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
502
395
/>
503
396
</ RovingAccessibleTooltipButton >
504
397
</ div >
505
- { customStatusSection }
506
398
{ topSection }
507
399
{ primaryOptionList }
508
400
</ IconizedContextMenu > ;
@@ -515,11 +407,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
515
407
const displayName = OwnProfileStore . instance . displayName || userId ;
516
408
const avatarUrl = OwnProfileStore . instance . getHttpAvatarUrl ( avatarSize ) ;
517
409
518
- let badge : JSX . Element ;
519
- if ( this . state . dndEnabled ) {
520
- badge = < div className = "mx_UserMenu_dndBadge" /> ;
521
- }
522
-
523
410
let name : JSX . Element ;
524
411
if ( ! this . props . isPanelCollapsed ) {
525
412
name = < div className = "mx_UserMenu_name" >
@@ -534,9 +421,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
534
421
label = { _t ( "User menu" ) }
535
422
isExpanded = { ! ! this . state . contextMenuPosition }
536
423
onContextMenu = { this . onContextMenu }
537
- className = { classNames ( {
538
- mx_UserMenu_cutout : badge ,
539
- } ) }
540
424
>
541
425
< div className = "mx_UserMenu_userAvatar" >
542
426
< BaseAvatar
@@ -548,7 +432,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
548
432
resizeMethod = "crop"
549
433
className = "mx_UserMenu_userAvatar_BaseAvatar"
550
434
/>
551
- { badge }
552
435
</ div >
553
436
{ name }
554
437
0 commit comments