@@ -48,9 +48,8 @@ function UserUnknownDeviceList(props) {
48
48
const { userId, userDevices} = props ;
49
49
50
50
const deviceListEntries = Object . keys ( userDevices ) . map ( ( deviceId ) =>
51
- < DeviceListEntry key = { deviceId } userId = { userId }
52
- device = { userDevices [ deviceId ] }
53
- /> ,
51
+ < DeviceListEntry key = { deviceId } userId = { userId }
52
+ device = { userDevices [ deviceId ] } /> ,
54
53
) ;
55
54
56
55
return (
@@ -93,60 +92,26 @@ export default React.createClass({
93
92
propTypes : {
94
93
room : React . PropTypes . object . isRequired ,
95
94
95
+ // map from userid -> deviceid -> deviceinfo
96
+ devices : React . PropTypes . object . isRequired ,
96
97
onFinished : React . PropTypes . func . isRequired ,
97
98
} ,
98
99
99
- componentWillMount : function ( ) {
100
- this . _unmounted = false ;
101
-
102
- const roomMembers = this . props . room . getJoinedMembers ( ) . map ( ( m ) => {
103
- return m . userId ;
104
- } ) ;
105
-
106
- this . setState ( {
107
- // map from userid -> deviceid -> deviceinfo
108
- devices : null ,
109
- } ) ;
110
- MatrixClientPeg . get ( ) . downloadKeys ( roomMembers , false ) . then ( ( devices ) => {
111
- if ( this . _unmounted ) return ;
112
-
113
- const unknownDevices = { } ;
114
- // This is all devices in this room, so find the unknown ones.
115
- Object . keys ( devices ) . forEach ( ( userId ) => {
116
- Object . keys ( devices [ userId ] ) . map ( ( deviceId ) => {
117
- const device = devices [ userId ] [ deviceId ] ;
118
-
119
- if ( device . isUnverified ( ) && ! device . isKnown ( ) ) {
120
- if ( unknownDevices [ userId ] === undefined ) {
121
- unknownDevices [ userId ] = { } ;
122
- }
123
- unknownDevices [ userId ] [ deviceId ] = device ;
124
- }
125
-
126
- // Given we've now shown the user the unknown device, it is no longer
127
- // unknown to them. Therefore mark it as 'known'.
128
- if ( ! device . isKnown ( ) ) {
129
- MatrixClientPeg . get ( ) . setDeviceKnown ( userId , deviceId , true ) ;
130
- }
131
- } ) ;
132
- } ) ;
133
-
134
- this . setState ( {
135
- devices : unknownDevices ,
100
+ componentDidMount : function ( ) {
101
+ // Given we've now shown the user the unknown device, it is no longer
102
+ // unknown to them. Therefore mark it as 'known'.
103
+ Object . keys ( this . props . devices ) . forEach ( ( userId ) => {
104
+ Object . keys ( this . props . devices [ userId ] ) . map ( ( deviceId ) => {
105
+ MatrixClientPeg . get ( ) . setDeviceKnown ( userId , deviceId , true ) ;
136
106
} ) ;
137
107
} ) ;
138
- } ,
139
108
140
- componentWillUnmount : function ( ) {
141
- this . _unmounted = true ;
109
+ // XXX: temporary logging to try to diagnose
110
+ // https://github.com/vector-im/riot-web/issues/3148
111
+ console . log ( 'Opening UnknownDeviceDialog' ) ;
142
112
} ,
143
113
144
114
render : function ( ) {
145
- if ( this . state . devices === null ) {
146
- const Spinner = sdk . getComponent ( "elements.Spinner" ) ;
147
- return < Spinner /> ;
148
- }
149
-
150
115
const client = MatrixClientPeg . get ( ) ;
151
116
const blacklistUnverified = client . getGlobalBlacklistUnverifiedDevices ( ) ||
152
117
this . props . room . getBlacklistUnverifiedDevices ( ) ;
@@ -189,7 +154,7 @@ export default React.createClass({
189
154
{ warning }
190
155
{ _t ( "Unknown devices" ) } :
191
156
192
- < UnknownDeviceList devices = { this . state . devices } />
157
+ < UnknownDeviceList devices = { this . props . devices } />
193
158
</ GeminiScrollbar >
194
159
< div className = "mx_Dialog_buttons" >
195
160
< button className = "mx_Dialog_primary" autoFocus = { true }
0 commit comments