Poll WIP (#231):

* close button
* backend fix
This commit is contained in:
John Livingston 2024-07-04 15:34:32 +02:00
parent ffb8ac8ddc
commit 1249f0895d
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
6 changed files with 25 additions and 2 deletions

View File

@ -53,6 +53,11 @@ export default class MUCPollView extends CustomElement {
body: '!' + choice.choice
})
}
closePoll (ev) {
ev.preventDefault()
this.model.set('current_poll', undefined)
}
}
api.elements.define('livechat-converse-muc-poll', MUCPollView)

View File

@ -71,7 +71,7 @@ converse.plugins.add('livechat-converse-poll', {
return this.__super__.onMessage(attrs)
}
// We intercept poll messages, to show the banner.
// Note: we also show the message in the chat.
// Note: we also show poll end messages in the chat, so that the user don't loose the result.
if (attrs.is_delayed || attrs.is_archived) {
if (attrs.current_poll.over) {
console.info('Got a delayed/archived poll message for an poll that is over, just displaying in the chat')

View File

@ -23,6 +23,12 @@
padding-right: 0.25em;
}
.livechat-poll-close {
background: unset;
border: 0;
float: right;
}
p.livechat-poll-question {
text-align: center;
font-weight: bold;

View File

@ -82,6 +82,12 @@ export function tplPoll (el, currentPoll) {
return html`<div class="${currentPoll.over ? 'livechat-poll-over' : ''}">
<p class="livechat-poll-question">
${currentPoll.over
? html`<button class="livechat-poll-close" @click=${el.closePoll} title="${__('Close')}">
<converse-icon class="fa fa-times" size="1em"></converse-icon>
</button>`
: ''
}
${el.collapsed
? html`
<button @click=${el.toggle} class="livechat-poll-toggle">

View File

@ -157,6 +157,11 @@ local function poll_end_message(room)
return nil;
end
module:log("debug", "Sending the end message for room %s poll", room.jid);
if scheduled_updates[room.jid] then
module:log("debug", "Cancelling an update message for the poll %s", room.jid);
timer.stop(scheduled_updates[room.jid]);
scheduled_updates[room.jid] = nil;
end
local message_id = id.medium(); -- generate a new id
local msg = build_poll_message(room, message_id, true);
room:broadcast_message(msg);

View File

@ -13,6 +13,7 @@ local schedule_poll_update_message = module:require("message").schedule_poll_upd
local string_poll_invalid_choice = module:get_option_string("poll_string_invalid_choice") or "This choice is not valid.";
local string_poll_anonymous_vote_ok = module:get_option_string("poll_string_anonymous_vote_ok") or "You vote is taken into account. Votes are anonymous, it will not be shown to other participants.";
local string_poll_over = module:get_option_string("poll_string_over") or "This poll is now over.";
local scheduled_end = {};
@ -160,7 +161,7 @@ local function handle_groupchat(event)
"cancel",
-- error_condition = 'not-allowed' (see RFC 6120 Defined Error Conditions https://xmpp.org/rfcs/rfc6120.html#stanzas-error-conditions)
"not-allowed",
"This poll is over."
string_poll_over
));
return true; -- stop!
end