@@ -51,19 +51,14 @@ class Device extends Component {
51
51
52
52
state = {
53
53
firmwareVersion : null ,
54
- deviceRegistered : false ,
55
54
deviceStatus : '' ,
56
55
goal : '' ,
57
56
success : null ,
58
57
} ;
59
58
60
59
componentDidMount ( ) {
61
- this . onDevicesRegisteredChanged ( ) ;
62
60
this . onDeviceStatusChanged ( ) ;
63
61
this . unsubscribe = apiWebsocket ( ( { type, data, deviceID } ) => {
64
- if ( type === 'devices' && data === 'registeredChanged' ) {
65
- this . onDevicesRegisteredChanged ( ) ;
66
- }
67
62
if ( type === 'device' && data === 'statusChanged' && deviceID === this . getDeviceID ( ) ) {
68
63
this . onDeviceStatusChanged ( ) ;
69
64
}
@@ -76,40 +71,15 @@ class Device extends Component {
76
71
}
77
72
}
78
73
79
- componentDidUpdate ( prevProps ) {
80
- if ( this . props . deviceID !== prevProps . deviceID ) {
81
- this . onDevicesRegisteredChanged ( ) ;
82
- }
83
- }
84
-
85
- onDevicesRegisteredChanged = ( ) => {
86
- apiGet ( 'devices/registered' ) . then ( devices => {
87
- const deviceIDs = Object . keys ( devices ) ;
88
- const deviceRegistered = deviceIDs . includes ( this . getDeviceID ( ) ) ;
89
-
90
- this . setState ( {
91
- deviceRegistered,
92
- deviceStatus : null
93
- } , ( ) => {
94
- // only if deviceRegistered or softwarekeystore
95
- if ( this . state . deviceRegistered ) {
96
- this . onDeviceStatusChanged ( ) ;
97
- }
98
- } ) ;
99
- } ) ;
100
- } ;
101
-
102
74
onDeviceStatusChanged = ( ) => {
103
- if ( this . state . deviceRegistered ) {
104
- apiGet ( 'devices/' + this . props . deviceID + '/status' ) . then ( deviceStatus => {
105
- if ( [ 'seeded' , 'initialized' ] . includes ( deviceStatus ) ) {
106
- this . context . setSidebarStatus ( '' ) ;
107
- } else {
108
- this . context . setSidebarStatus ( 'forceHidden' ) ;
109
- }
110
- this . setState ( { deviceStatus } ) ;
111
- } ) ;
112
- }
75
+ apiGet ( 'devices/' + this . props . deviceID + '/status' ) . then ( deviceStatus => {
76
+ if ( [ 'seeded' , 'initialized' ] . includes ( deviceStatus ) ) {
77
+ this . context . setSidebarStatus ( '' ) ;
78
+ } else {
79
+ this . context . setSidebarStatus ( 'forceHidden' ) ;
80
+ }
81
+ this . setState ( { deviceStatus } ) ;
82
+ } ) ;
113
83
} ;
114
84
115
85
getDeviceID ( ) {
@@ -137,12 +107,11 @@ class Device extends Component {
137
107
deviceID,
138
108
} = this . props ;
139
109
const {
140
- deviceRegistered,
141
110
deviceStatus,
142
111
goal,
143
112
success,
144
113
} = this . state ;
145
- if ( ! deviceRegistered || ! deviceStatus ) {
114
+ if ( ! deviceStatus ) {
146
115
return null ;
147
116
}
148
117
if ( success ) {
0 commit comments