From 3e6ebdd23bd38d4b0e4f9902b049162137b7e0de Mon Sep 17 00:00:00 2001
From: Fabio Manganiello <info@fabiomanganiello.com>
Date: Sun, 23 Oct 2022 00:28:01 +0200
Subject: [PATCH] Don't store/show the state of write-only toggle switches

---
 .../src/components/panels/Entities/Switch.vue      | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/platypush/backend/http/webapp/src/components/panels/Entities/Switch.vue b/platypush/backend/http/webapp/src/components/panels/Entities/Switch.vue
index 89943657..980ceb0a 100644
--- a/platypush/backend/http/webapp/src/components/panels/Entities/Switch.vue
+++ b/platypush/backend/http/webapp/src/components/panels/Entities/Switch.vue
@@ -11,8 +11,11 @@
       </div>
 
       <div class="col-2 switch pull-right">
-        <ToggleSwitch :value="value.state" @input="toggle"
-          @click.stop :disabled="loading || value.is_read_only" />
+        <ToggleSwitch
+          :value="value.is_write_only ? false : value.state"
+          :disabled="loading || value.is_read_only" 
+          @input="toggle"
+          @click.stop />
       </div>
     </div>
   </div>
@@ -38,6 +41,13 @@ export default {
           id: this.value.id,
           action: 'toggle',
         })
+
+        if (this.value.is_write_only) {
+          // Show a quick on/off animation for write-only switches
+          const self = this
+          self.value.state = true
+          setTimeout(() => self.value.state = false, 250)
+        }
       } finally {
         this.$emit('loading', false)
       }