@@ -14,9 +14,8 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import React , { createRef , useContext , useRef , useState } from "react" ;
17+ import React , { createRef } from "react" ;
1818import { Room } from "matrix-js-sdk/src/models/room" ;
19- import classNames from "classnames" ;
2019
2120import { MatrixClientPeg } from "../../MatrixClientPeg" ;
2221import defaultDispatcher from "../../dispatcher/dispatcher" ;
@@ -32,9 +31,7 @@ import LogoutDialog from "../views/dialogs/LogoutDialog";
3231import SettingsStore from "../../settings/SettingsStore" ;
3332import { findHighContrastTheme , getCustomTheme , isHighContrastTheme } from "../../theme" ;
3433import {
35- RovingAccessibleButton ,
3634 RovingAccessibleTooltipButton ,
37- useRovingTabIndex ,
3835} from "../../accessibility/RovingTabIndex" ;
3936import AccessibleButton , { ButtonEvent } from "../views/elements/AccessibleButton" ;
4037import SdkConfig from "../../SdkConfig" ;
@@ -44,73 +41,17 @@ import { UPDATE_EVENT } from "../../stores/AsyncStore";
4441import BaseAvatar from '../views/avatars/BaseAvatar' ;
4542import { SettingLevel } from "../../settings/SettingLevel" ;
4643import IconizedContextMenu , {
47- IconizedContextMenuCheckbox ,
4844 IconizedContextMenuOption ,
4945 IconizedContextMenuOptionList ,
5046} from "../views/context_menus/IconizedContextMenu" ;
5147import { UIFeature } from "../../settings/UIFeature" ;
5248import HostSignupAction from "./HostSignupAction" ;
5349import SpaceStore from "../../stores/spaces/SpaceStore" ;
5450import { UPDATE_SELECTED_SPACE } from "../../stores/spaces" ;
55- import MatrixClientContext from "../../contexts/MatrixClientContext" ;
56- import { SettingUpdatedPayload } from "../../dispatcher/payloads/SettingUpdatedPayload" ;
5751import UserIdentifierCustomisations from "../../customisations/UserIdentifier" ;
5852import PosthogTrackers from "../../PosthogTrackers" ;
5953import { ViewHomePagePayload } from "../../dispatcher/payloads/ViewHomePagePayload" ;
6054
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-
11455interface IProps {
11556 isPanelCollapsed : boolean ;
11657}
@@ -122,7 +63,6 @@ interface IState {
12263 isDarkTheme : boolean ;
12364 isHighContrast : boolean ;
12465 selectedSpace ?: Room ;
125- dndEnabled : boolean ;
12666}
12767
12868const toRightOf = ( rect : PartialDOMRect ) => {
@@ -154,19 +94,11 @@ export default class UserMenu extends React.Component<IProps, IState> {
15494 contextMenuPosition : null ,
15595 isDarkTheme : this . isUserOnDarkTheme ( ) ,
15696 isHighContrast : this . isUserOnHighContrastTheme ( ) ,
157- dndEnabled : this . doNotDisturb ,
15897 selectedSpace : SpaceStore . instance . activeSpaceRoom ,
15998 } ;
16099
161100 OwnProfileStore . instance . on ( UPDATE_EVENT , this . onProfileUpdate ) ;
162101 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" ) ;
170102 }
171103
172104 private get hasHomePage ( ) : boolean {
@@ -239,20 +171,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
239171 if ( this . buttonRef . current ) this . buttonRef . current . click ( ) ;
240172 }
241173 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- }
256174 }
257175 } ;
258176
@@ -348,12 +266,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
348266 this . setState ( { contextMenuPosition : null } ) ; // also close the menu
349267 } ;
350268
351- private onDndToggle = ( ev : ButtonEvent ) => {
352- ev . stopPropagation ( ) ;
353- const current = SettingsStore . getValue ( "doNotDisturb" ) ;
354- SettingsStore . setValue ( "doNotDisturb" , null , SettingLevel . DEVICE , ! current ) ;
355- } ;
356-
357269 private renderContextMenu = ( ) : React . ReactNode => {
358270 if ( ! this . state . contextMenuPosition ) return null ;
359271
@@ -400,24 +312,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
400312 ) ;
401313 }
402314
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-
421315 let feedbackButton ;
422316 if ( SettingsStore . getValue ( UIFeature . Feedback ) ) {
423317 feedbackButton = < IconizedContextMenuOption
@@ -430,7 +324,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
430324 let primaryOptionList = (
431325 < IconizedContextMenuOptionList >
432326 { homeButton }
433- { dndButton }
434327 < IconizedContextMenuOption
435328 iconClassName = "mx_UserMenu_iconBell"
436329 label = { _t ( "Notifications" ) }
@@ -502,7 +395,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
502395 />
503396 </ RovingAccessibleTooltipButton >
504397 </ div >
505- { customStatusSection }
506398 { topSection }
507399 { primaryOptionList }
508400 </ IconizedContextMenu > ;
@@ -515,11 +407,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
515407 const displayName = OwnProfileStore . instance . displayName || userId ;
516408 const avatarUrl = OwnProfileStore . instance . getHttpAvatarUrl ( avatarSize ) ;
517409
518- let badge : JSX . Element ;
519- if ( this . state . dndEnabled ) {
520- badge = < div className = "mx_UserMenu_dndBadge" /> ;
521- }
522-
523410 let name : JSX . Element ;
524411 if ( ! this . props . isPanelCollapsed ) {
525412 name = < div className = "mx_UserMenu_name" >
@@ -534,9 +421,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
534421 label = { _t ( "User menu" ) }
535422 isExpanded = { ! ! this . state . contextMenuPosition }
536423 onContextMenu = { this . onContextMenu }
537- className = { classNames ( {
538- mx_UserMenu_cutout : badge ,
539- } ) }
540424 >
541425 < div className = "mx_UserMenu_userAvatar" >
542426 < BaseAvatar
@@ -548,7 +432,6 @@ export default class UserMenu extends React.Component<IProps, IState> {
548432 resizeMethod = "crop"
549433 className = "mx_UserMenu_userAvatar_BaseAvatar"
550434 />
551- { badge }
552435 </ div >
553436 { name }
554437
0 commit comments