diff --git a/conversejs/custom/plugins/poll/components/poll-view.js b/conversejs/custom/plugins/poll/components/poll-view.js index 422aba72..e96b5f3b 100644 --- a/conversejs/custom/plugins/poll/components/poll-view.js +++ b/conversejs/custom/plugins/poll/components/poll-view.js @@ -4,7 +4,7 @@ import { tplPoll } from '../templates/poll.js' import { CustomElement } from 'shared/components/element.js' -import { api } from '@converse/headless/core' +import { converse, api } from '@converse/headless/core' import '../styles/poll.scss' export default class MUCPollView extends CustomElement { @@ -30,7 +30,9 @@ export default class MUCPollView extends CustomElement { render () { const currentPoll = this.model?.get('current_poll') - return tplPoll(this, currentPoll) + const entered = this.model.session.get('connection_status') === converse.ROOMSTATUS.ENTERED + const canVote = entered && this.model.getOwnRole() !== 'visitor' + return tplPoll(this, currentPoll, canVote) } toggle (ev) { diff --git a/conversejs/custom/plugins/poll/templates/poll.js b/conversejs/custom/plugins/poll/templates/poll.js index bd976b6d..03ad095f 100644 --- a/conversejs/custom/plugins/poll/templates/poll.js +++ b/conversejs/custom/plugins/poll/templates/poll.js @@ -31,9 +31,9 @@ function _tplPollEnd (el, currentPoll) {

` } -function _tplChoice (el, currentPoll, choice) { +function _tplChoice (el, currentPoll, choice, canVote) { // eslint-disable-next-line no-undef - const i18nChoiceN = __(LOC_poll_choice_n).replace('{{N}}', choice.choice) + const i18nChoiceN = '' + choice.choice + ':' const votes = choice.votes const totalVotes = currentPoll.votes @@ -42,7 +42,7 @@ function _tplChoice (el, currentPoll, choice) { ${ - currentPoll.over + currentPoll.over || !canVote ? html`${i18nChoiceN}` : html`