diff options
author | Marco Ambrosini <marcoambrosini@icloud.com> | 2022-08-24 18:38:04 +0300 |
---|---|---|
committer | Marco Ambrosini <marcoambrosini@icloud.com> | 2022-08-26 11:57:32 +0300 |
commit | d04c9a3f3a943fe831f45a372658b140bed59b7a (patch) | |
tree | aaa48b849157011142a961231e3ddc91a02c8d3e /src/components | |
parent | 2748e48942583e9b48493650f5e259380bdde26e (diff) |
Show if user has voted or not in poll preview
Signed-off-by: Marco Ambrosini <marcoambrosini@icloud.com>
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue index 8f59bac08..81e69a332 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue @@ -33,8 +33,9 @@ </p> </div> <div class="poll__footer"> - {{ t('spreed', 'Poll ・ Click to vote') }} + {{ selfHasVoted ? t('spreed', 'Poll ・ You voted') : t('spreed', 'Poll ・ Click to vote') }} </div> + </a> <!-- voting and results dialog --> @@ -213,6 +214,19 @@ export default { }, selfHasVoted() { + if (this.pollLoaded) { + if (typeof this.votedSelf === 'object') { + return this.votedSelf.length > 0 + } else { + return !!this.votedSelf + } + } else { + return undefined + } + }, + + // The actual vote of the user as returned from the server + votedSelf() { return this.pollLoaded ? this.poll.votedSelf : undefined }, @@ -316,12 +330,12 @@ export default { if (this.checkboxRadioSwitchType === 'radio') { this.vote = '' if (this.selfHasVoted) { - this.vote = this.selfHasVoted[0].toString() + this.vote = this.votedSelf[0].toString() } } else { this.vote = [] if (this.selfHasVoted) { - this.vote = this.selfHasVoted.map(element => element.toString()) + this.vote = this.votedSelf.map(element => element.toString()) } } }, @@ -329,6 +343,8 @@ export default { openPoll() { if (this.selfHasVoted) { this.modalPage = 'results' + } else { + this.modalPage = 'voting' } this.showModal = true }, |