|
|
@@ -161,13 +161,17 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
onMessage (topic) {
|
|
|
- if (!this.deviceOptions.loaded || !this.deviceOptions.list.length) {
|
|
|
+ if (this.deviceOptions.loaded && !this.deviceOptions.list.length) {
|
|
|
return
|
|
|
}
|
|
|
const result = /^[^/]+\/(.+)\/(online|offline)$/.exec(topic)
|
|
|
if (result) {
|
|
|
+ if (!this.deviceOptions.loaded) {
|
|
|
+ this.refreshDevices()
|
|
|
+ return
|
|
|
+ }
|
|
|
const deviceId = result[1]
|
|
|
- const device = this.deviceOptions.list.find(({ id, onlineStatus }) => id === deviceId)
|
|
|
+ const device = this.deviceOptions.list.find(({ id }) => id === deviceId)
|
|
|
if (device && (result[2] === 'online' && device.onlineStatus !== 1 || result[2] === 'offline' && device.onlineStatus === 1)) {
|
|
|
this.refreshDevices()
|
|
|
}
|