From 2a7bfad711576e02a0267634cd34ec592700cdd3 Mon Sep 17 00:00:00 2001 From: armored-dragon Date: Wed, 4 Sep 2024 16:07:27 -0500 Subject: [PATCH] Don't close all polls when you close yours. --- applications/voting/vote.js | 7 +++++-- applications/voting/vote.qml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/applications/voting/vote.js b/applications/voting/vote.js index 5d64311..ade668e 100644 --- a/applications/voting/vote.js +++ b/applications/voting/vote.js @@ -14,6 +14,7 @@ // TODO: Documentation // TODO: Save questions and answers locally // TODO: Allow more than 9 candidates +// TODO: Allow host voting (() => { "use strict"; @@ -247,11 +248,13 @@ // Polls closed :) if (message.type == "close_poll") { + var isOurPoll = poll.id == message.poll.id; + // Tell UI to close poll - _emitEvent({type: "close_poll", poll: {id: message.poll.id}}); + _emitEvent({type: "close_poll", change_page: isOurPoll, poll: {id: message.poll.id}}); // Unregister self from poll - leavePoll(); + if (isOurPoll) leavePoll(); } break; diff --git a/applications/voting/vote.qml b/applications/voting/vote.qml index 09e2365..8e1159e 100644 --- a/applications/voting/vote.qml +++ b/applications/voting/vote.qml @@ -627,7 +627,7 @@ Rectangle { // Close the poll and remove it from the list of active polls case "close_poll": - current_page = "poll_list" + if (message.isOurPoll) current_page = "poll_list" // Find the poll with the matching ID and remove it from active polls for (var i = 0; i < active_polls.count; i++) {