From d41eafda07694603ebcac07f6207b62365c69e4d Mon Sep 17 00:00:00 2001 From: Steffen Date: Fri, 5 Jun 2020 22:12:51 +0200 Subject: [PATCH] fix votes --- package-lock.json | 29 ++++++++++++++++++++++++++++- src/App.vue | 2 +- src/store/socket.js | 21 ++++++++++++++++++--- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 88968a6..76335a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1042,6 +1042,15 @@ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==" }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -3409,6 +3418,12 @@ "schema-utils": "^2.5.0" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "optional": true + }, "filesize": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/filesize/-/filesize-3.6.1.tgz", @@ -5303,6 +5318,12 @@ "thenify-all": "^1.0.0" } }, + "nan": { + "version": "2.14.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", + "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==", + "optional": true + }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -8614,6 +8635,8 @@ "integrity": "sha512-Ggd/Ktt7E7I8pxZRbGIs7vwqAPscSESMrCSkx2FtWeqmheJgCo2R74fTsZFCifr0VTPwqRpPv17+6b8Zp7th0Q==", "optional": true, "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1", "node-pre-gyp": "*" }, "dependencies": { @@ -9434,7 +9457,11 @@ "version": "1.2.13", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "optional": true + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } }, "glob-parent": { "version": "3.1.0", diff --git a/src/App.vue b/src/App.vue index 34f83ed..b3c5db3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -173,7 +173,7 @@ ul { .zoom-enter, .zoom-leave-to { opacity: 0; - filter: blur(20px) + filter: blur(20px); } // Buttons diff --git a/src/store/socket.js b/src/store/socket.js index c999203..21612e1 100644 --- a/src/store/socket.js +++ b/src/store/socket.js @@ -103,7 +103,7 @@ class LiveSession { this._store.commit("session/nomination", params); break; case "vote": - this._store.commit("session/vote", params); + this._handleVote(params); break; case "lock": this._store.commit("session/lockVote", params); @@ -386,11 +386,26 @@ class LiveSession { /** * Send a vote. Player only - * @param index + * @param index Seat of the player */ vote([index]) { if (!this._isSpectator) return; - this._send("vote", [index, this._store.state.session.votes[index]]); + const player = this._store.state.players.players[index]; + if (this._store.state.session.playerId === player.id) { + // send vote only if it is your own vote + this._send("vote", [index, this._store.state.session.votes[index]]); + } + } + + /** + * Handle an incoming vote, but not if it is for your own seat. + * @param vote + */ + _handleVote(vote) { + const player = this._store.state.players.players[vote[0]]; + if (this._store.state.session.playerId !== player.id) { + this._store.commit("session/vote", vote); + } } /**