@@ -27,6 +27,28 @@ export default React.createClass({
27
27
device : React . PropTypes . object . isRequired ,
28
28
} ,
29
29
30
+ getInitialState : function ( ) {
31
+ return {
32
+ device : this . props . device
33
+ } ;
34
+ } ,
35
+
36
+ componentWillMount : function ( ) {
37
+ const cli = MatrixClientPeg . get ( ) ;
38
+ cli . on ( "deviceVerificationChanged" , this . onDeviceVerificationChanged ) ;
39
+ } ,
40
+
41
+ componentWillUnmount : function ( ) {
42
+ const cli = MatrixClientPeg . get ( ) ;
43
+ cli . removeListener ( "deviceVerificationChanged" , this . onDeviceVerificationChanged ) ;
44
+ } ,
45
+
46
+ onDeviceVerificationChanged : function ( userId , deviceId ) {
47
+ if ( userId === this . props . userId && deviceId === this . props . device . deviceId ) {
48
+ this . setState ( { device : MatrixClientPeg . get ( ) . getStoredDevice ( userId , deviceId ) } ) ;
49
+ }
50
+ } ,
51
+
30
52
onVerifyClick : function ( ) {
31
53
var QuestionDialog = sdk . getComponent ( "dialogs.QuestionDialog" ) ;
32
54
Modal . createDialog ( QuestionDialog , {
@@ -41,9 +63,9 @@ export default React.createClass({
41
63
</ p >
42
64
< div className = "mx_UserSettings_cryptoSection" >
43
65
< ul >
44
- < li > < label > Device name:</ label > < span > { this . props . device . getDisplayName ( ) } </ span > </ li >
45
- < li > < label > Device ID:</ label > < span > < code > { this . props . device . deviceId } </ code > </ span > </ li >
46
- < li > < label > Device key:</ label > < span > < code > < b > { this . props . device . getFingerprint ( ) } </ b > </ code > </ span > </ li >
66
+ < li > < label > Device name:</ label > < span > { this . state . device . getDisplayName ( ) } </ span > </ li >
67
+ < li > < label > Device ID:</ label > < span > < code > { this . state . device . deviceId } </ code > </ span > </ li >
68
+ < li > < label > Device key:</ label > < span > < code > < b > { this . state . device . getFingerprint ( ) } </ b > </ code > </ span > </ li >
47
69
</ ul >
48
70
</ div >
49
71
< p >
@@ -60,7 +82,7 @@ export default React.createClass({
60
82
onFinished : confirm => {
61
83
if ( confirm ) {
62
84
MatrixClientPeg . get ( ) . setDeviceVerified (
63
- this . props . userId , this . props . device . deviceId , true
85
+ this . props . userId , this . state . device . deviceId , true
64
86
) ;
65
87
}
66
88
} ,
@@ -69,26 +91,26 @@ export default React.createClass({
69
91
70
92
onUnverifyClick : function ( ) {
71
93
MatrixClientPeg . get ( ) . setDeviceVerified (
72
- this . props . userId , this . props . device . deviceId , false
94
+ this . props . userId , this . state . device . deviceId , false
73
95
) ;
74
96
} ,
75
97
76
98
onBlacklistClick : function ( ) {
77
99
MatrixClientPeg . get ( ) . setDeviceBlocked (
78
- this . props . userId , this . props . device . deviceId , true
100
+ this . props . userId , this . state . device . deviceId , true
79
101
) ;
80
102
} ,
81
103
82
104
onUnblacklistClick : function ( ) {
83
105
MatrixClientPeg . get ( ) . setDeviceBlocked (
84
- this . props . userId , this . props . device . deviceId , false
106
+ this . props . userId , this . state . device . deviceId , false
85
107
) ;
86
108
} ,
87
109
88
110
render : function ( ) {
89
111
var blacklistButton = null , verifyButton = null ;
90
112
91
- if ( this . props . device . isBlocked ( ) ) {
113
+ if ( this . state . device . isBlocked ( ) ) {
92
114
blacklistButton = (
93
115
< button className = "mx_MemberDeviceInfo_textButton mx_MemberDeviceInfo_unblacklist"
94
116
onClick = { this . onUnblacklistClick } >
@@ -104,7 +126,7 @@ export default React.createClass({
104
126
) ;
105
127
}
106
128
107
- if ( this . props . device . isVerified ( ) ) {
129
+ if ( this . state . device . isVerified ( ) ) {
108
130
verifyButton = (
109
131
< button className = "mx_MemberDeviceInfo_textButton mx_MemberDeviceInfo_unverify"
110
132
onClick = { this . onUnverifyClick } >
0 commit comments