From 0bbbb8049d2c07505edbb24594810ec048266fbb Mon Sep 17 00:00:00 2001 From: ori agranat Date: Mon, 16 Sep 2019 23:54:31 +0300 Subject: [PATCH] added client test for the same message --- chameleon-client/src/App.vue | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/chameleon-client/src/App.vue b/chameleon-client/src/App.vue index da749dd31..7e076e612 100644 --- a/chameleon-client/src/App.vue +++ b/chameleon-client/src/App.vue @@ -67,6 +67,20 @@ this.$refs.menu.updateOpened(); this.$refs.menu.updateActiveName(); }) + }, + isEquale(message,prop){ + if(typeof (this.$store.state[prop]) == "object"){ + for(var i = this.$store.state[prop].length; i--;) { + if(this.$store.state[prop][i] !== message[prop][i]){ + return false; + } + } + } else{ + if(this.$store.state[prop] != message[prop]){ + return false + } + } + return true; } }, computed: { @@ -86,9 +100,14 @@ let message = JSON.parse(data.data); for (var prop in message){ if(message.hasOwnProperty(prop)){ - this.$store.state[prop] = message[prop]; + if(!this.isEquale(message,prop)){ + this.$store.state[prop] = message[prop]; + console.log(message); + } else{ + console.log("data is the same"); + } } - console.log(data.data); + } } catch{