11/*
2- Copyright 2015, 2016 OpenMarket Ltd
3- Copyright 2017 New Vector Ltd
2+ Copyright 2015, 2016, 2017, 2020 The Matrix.org Foundation C.I.C.
43
54Licensed under the Apache License, Version 2.0 (the "License");
65you may not use this file except in compliance with the License.
@@ -16,8 +15,8 @@ limitations under the License.
1615*/
1716
1817import React from 'react' ;
19- import PropTypes from 'prop-types' ;
2018import { MatrixClientPeg } from "../../../MatrixClientPeg" ;
19+ import { Room } from 'matrix-js-sdk/src/models/room'
2120import * as sdk from '../../../index' ;
2221import dis from "../../../dispatcher/dispatcher" ;
2322import * as ObjectUtils from '../../../ObjectUtils' ;
@@ -29,28 +28,42 @@ import SettingsStore from "../../../settings/SettingsStore";
2928import AutoHideScrollbar from "../../structures/AutoHideScrollbar" ;
3029import CallView from "../voip/CallView" ;
3130import { UIFeature } from "../../../settings/UIFeature" ;
31+ import { ResizeNotifier } from "../../../utils/ResizeNotifier" ;
3232
33+ interface IProps {
34+ // js-sdk room object
35+ room : Room ,
36+ userId : string ,
37+ showApps : boolean , // Render apps
3338
34- export default class AuxPanel extends React . Component {
35- static propTypes = {
36- // js-sdk room object
37- room : PropTypes . object . isRequired ,
38- userId : PropTypes . string . isRequired ,
39- showApps : PropTypes . bool , // Render apps
39+ // set to true to show the file drop target
40+ draggingFile : boolean ,
4041
41- // set to true to show the file drop target
42- draggingFile : PropTypes . bool ,
42+ // maxHeight attribute for the aux panel and the video
43+ // therein
44+ maxHeight : number ,
4345
44- // maxHeight attribute for the aux panel and the video
45- // therein
46- maxHeight : PropTypes . number ,
46+ // a callback which is called when the content of the aux panel changes
47+ // content in a way that is likely to make it change size.
48+ onResize : ( ) => void ,
49+ fullHeight : boolean ,
4750
48- // a callback which is called when the content of the aux panel changes
49- // content in a way that is likely to make it change size.
50- onResize : PropTypes . func ,
51- fullHeight : PropTypes . bool ,
52- } ;
51+ resizeNotifier : ResizeNotifier ,
52+ }
53+
54+ interface Counter {
55+ title : string ,
56+ value : number ,
57+ link : string ,
58+ severity : string ,
59+ stateKey : string ,
60+ }
5361
62+ interface IState {
63+ counters : Counter [ ] ,
64+ }
65+
66+ export default class AuxPanel extends React . Component < IProps , IState > {
5467 static defaultProps = {
5568 showApps : true ,
5669 } ;
@@ -104,15 +117,15 @@ export default class AuxPanel extends React.Component {
104117 } , 500 ) ;
105118
106119 _computeCounters ( ) {
107- let counters = [ ] ;
120+ const counters = [ ] ;
108121
109122 if ( this . props . room && SettingsStore . getValue ( "feature_state_counters" ) ) {
110123 const stateEvs = this . props . room . currentState . getStateEvents ( 're.jki.counter' ) ;
111124 stateEvs . sort ( ( a , b ) => {
112125 return a . getStateKey ( ) < b . getStateKey ( ) ;
113126 } ) ;
114127
115- stateEvs . forEach ( ( ev , idx ) => {
128+ for ( const ev of stateEvs ) {
116129 const title = ev . getContent ( ) . title ;
117130 const value = ev . getContent ( ) . value ;
118131 const link = ev . getContent ( ) . link ;
@@ -123,14 +136,14 @@ export default class AuxPanel extends React.Component {
123136 // zero)
124137 if ( title && value !== undefined ) {
125138 counters . push ( {
126- "title" : title ,
127- "value" : value ,
128- "link" : link ,
129- "severity" : severity ,
130- " stateKey" : stateKey
139+ title,
140+ value,
141+ link,
142+ severity,
143+ stateKey,
131144 } )
132145 }
133- } ) ;
146+ }
134147 }
135148
136149 return counters ;
@@ -143,8 +156,7 @@ export default class AuxPanel extends React.Component {
143156 if ( this . props . draggingFile ) {
144157 fileDropTarget = (
145158 < div className = "mx_RoomView_fileDropTarget" >
146- < div className = "mx_RoomView_fileDropTargetLabel"
147- title = { _t ( "Drop File Here" ) } >
159+ < div className = "mx_RoomView_fileDropTargetLabel" title = { _t ( "Drop File Here" ) } >
148160 < TintableSvg src = { require ( "../../../../res/img/upload-big.svg" ) } width = "45" height = "59" />
149161 < br />
150162 { _t ( "Drop file here to upload" ) }
@@ -208,7 +220,7 @@ export default class AuxPanel extends React.Component {
208220 < span
209221 className = "m_RoomView_auxPanel_stateViews_delim"
210222 key = { "delim" + idx }
211- > ─ </ span >
223+ > ─ </ span > ,
212224 ) ;
213225 } ) ;
214226
@@ -226,7 +238,7 @@ export default class AuxPanel extends React.Component {
226238 "mx_RoomView_auxPanel" : true ,
227239 "mx_RoomView_auxPanel_fullHeight" : this . props . fullHeight ,
228240 } ) ;
229- const style = { } ;
241+ const style : React . CSSProperties = { } ;
230242 if ( ! this . props . fullHeight ) {
231243 style . maxHeight = this . props . maxHeight ;
232244 }
0 commit comments