@@ -25,7 +25,6 @@ import { IContent } from "matrix-js-sdk/src/models/event";
25
25
import { Room } from "matrix-js-sdk/src/matrix" ;
26
26
27
27
import { _t , _td } from "../../../../../languageHandler" ;
28
- import { MatrixClientPeg } from "../../../../../MatrixClientPeg" ;
29
28
import AccessibleButton from "../../../elements/AccessibleButton" ;
30
29
import Modal from "../../../../../Modal" ;
31
30
import ErrorDialog from "../../../dialogs/ErrorDialog" ;
@@ -38,6 +37,7 @@ import SdkConfig, { DEFAULTS } from "../../../../../SdkConfig";
38
37
import { AddPrivilegedUsers } from "../../AddPrivilegedUsers" ;
39
38
import SettingsTab from "../SettingsTab" ;
40
39
import { SettingsSection } from "../../shared/SettingsSection" ;
40
+ import MatrixClientContext from "../../../../../contexts/MatrixClientContext" ;
41
41
42
42
interface IEventShowOpts {
43
43
isState ?: boolean ;
@@ -91,16 +91,17 @@ interface IBannedUserProps {
91
91
}
92
92
93
93
export class BannedUser extends React . Component < IBannedUserProps > {
94
+ public static contextType = MatrixClientContext ;
95
+ public context ! : React . ContextType < typeof MatrixClientContext > ;
96
+
94
97
private onUnbanClick = ( ) : void => {
95
- MatrixClientPeg . get ( )
96
- . unban ( this . props . member . roomId , this . props . member . userId )
97
- . catch ( ( err ) => {
98
- logger . error ( "Failed to unban: " + err ) ;
99
- Modal . createDialog ( ErrorDialog , {
100
- title : _t ( "Error" ) ,
101
- description : _t ( "Failed to unban" ) ,
102
- } ) ;
98
+ this . context . unban ( this . props . member . roomId , this . props . member . userId ) . catch ( ( err ) => {
99
+ logger . error ( "Failed to unban: " + err ) ;
100
+ Modal . createDialog ( ErrorDialog , {
101
+ title : _t ( "Error" ) ,
102
+ description : _t ( "Failed to unban" ) ,
103
103
} ) ;
104
+ } ) ;
104
105
} ;
105
106
106
107
public render ( ) : React . ReactNode {
@@ -136,12 +137,15 @@ interface IProps {
136
137
}
137
138
138
139
export default class RolesRoomSettingsTab extends React . Component < IProps > {
140
+ public static contextType = MatrixClientContext ;
141
+ public context ! : React . ContextType < typeof MatrixClientContext > ;
142
+
139
143
public componentDidMount ( ) : void {
140
- MatrixClientPeg . get ( ) . on ( RoomStateEvent . Update , this . onRoomStateUpdate ) ;
144
+ this . context . on ( RoomStateEvent . Update , this . onRoomStateUpdate ) ;
141
145
}
142
146
143
147
public componentWillUnmount ( ) : void {
144
- const client = MatrixClientPeg . get ( ) ;
148
+ const client = this . context ;
145
149
if ( client ) {
146
150
client . removeListener ( RoomStateEvent . Update , this . onRoomStateUpdate ) ;
147
151
}
@@ -173,7 +177,7 @@ export default class RolesRoomSettingsTab extends React.Component<IProps> {
173
177
}
174
178
175
179
private onPowerLevelsChanged = ( value : number , powerLevelKey : string ) : void => {
176
- const client = MatrixClientPeg . get ( ) ;
180
+ const client = this . context ;
177
181
const room = this . props . room ;
178
182
const plEvent = room . currentState . getStateEvents ( EventType . RoomPowerLevels , "" ) ;
179
183
let plContent = plEvent ?. getContent ( ) ?? { } ;
@@ -215,7 +219,7 @@ export default class RolesRoomSettingsTab extends React.Component<IProps> {
215
219
} ;
216
220
217
221
private onUserPowerLevelChanged = ( value : number , powerLevelKey : string ) : void => {
218
- const client = MatrixClientPeg . get ( ) ;
222
+ const client = this . context ;
219
223
const room = this . props . room ;
220
224
const plEvent = room . currentState . getStateEvents ( EventType . RoomPowerLevels , "" ) ;
221
225
let plContent = plEvent ?. getContent ( ) ?? { } ;
@@ -241,7 +245,7 @@ export default class RolesRoomSettingsTab extends React.Component<IProps> {
241
245
} ;
242
246
243
247
public render ( ) : React . ReactNode {
244
- const client = MatrixClientPeg . get ( ) ;
248
+ const client = this . context ;
245
249
const room = this . props . room ;
246
250
const isSpaceRoom = room . isSpaceRoom ( ) ;
247
251
0 commit comments