From 049a48e1564cd3f16de4caa65e8333620bcaec2a Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 15 Dec 2020 21:32:39 +0100 Subject: [PATCH] Fixed modified property Vue warning --- .../src/components/panels/Light/Index.vue | 19 +++++++++++-------- .../src/components/panels/LightHue/Index.vue | 9 ++++++++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/platypush/backend/http/webapp/src/components/panels/Light/Index.vue b/platypush/backend/http/webapp/src/components/panels/Light/Index.vue index 1621db8dd..aaa9e9094 100644 --- a/platypush/backend/http/webapp/src/components/panels/Light/Index.vue +++ b/platypush/backend/http/webapp/src/components/panels/Light/Index.vue @@ -31,7 +31,7 @@ export default { components: {Group, Groups}, mixins: [Utils, Panel], emits: ['group-toggle', 'light-toggle', 'set-light', 'set-group', 'select-scene', 'start-animation', 'stop-animation', - 'refresh'], + 'refresh', 'light-changed'], props: { lights: { @@ -182,13 +182,16 @@ export default { return } - delete event.plugin_name - delete event.type + const state = {...event} + const lightId = state.light_id + delete state.light_id + delete state.type + delete state.plugin_name - this.lights[event.light_id].state = { - ...(this.lights[event.light_id]?.state || {}), - ...event, - } + this.$emit('light-changed', { + id: lightId, + state: state, + }) }, onAnimationChange(event) { @@ -209,7 +212,7 @@ export default { this.initSelectedGroup() }, - destroyed() { + unmounted() { this.unsubscribe('on-light-change') this.unsubscribe('on-animation-change') }, diff --git a/platypush/backend/http/webapp/src/components/panels/LightHue/Index.vue b/platypush/backend/http/webapp/src/components/panels/LightHue/Index.vue index abb7ad218..7955d4d06 100644 --- a/platypush/backend/http/webapp/src/components/panels/LightHue/Index.vue +++ b/platypush/backend/http/webapp/src/components/panels/LightHue/Index.vue @@ -2,7 +2,7 @@ @@ -217,6 +217,13 @@ export default { await this.request('light.hue.stop_animation') await this.refresh(true) }, + + onLightChanged(event) { + this.lights[event.id].state = { + ...this.lights[event.id].state, + ...event.state, + } + }, }, mounted() {