diff options
author | Marco Ambrosini <marcoambrosini@icloud.com> | 2022-08-31 14:32:33 +0200 |
---|---|---|
committer | Marco Ambrosini <marcoambrosini@icloud.com> | 2022-08-31 14:32:37 +0200 |
commit | 75ae64f712f839089f615f880ee1a7943423af48 (patch) | |
tree | 697f1c494512f88ec5f9a5679d035523b408c4c2 /src | |
parent | 47b4f4d890966ddc8e96ffb553139b0fca1dae7c (diff) |
Filter details in a method
Signed-off-by: Marco Ambrosini <marcoambrosini@icloud.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue index fee80ad1b..c133eb383 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/Poll.vue @@ -130,11 +130,10 @@ {{ getVotePercentage(index) + '%' }} </p> </div> - <div class="results__option__details"> + <div v-if="getFilteredDetails(index).length > 0 || selfHasVotedOption(index)" + class="results__option__details"> <PollVotersDetails v-if="details" - :details="details.filter((item) => { - return item.optionId === index - }).slice(0, 8)" /> + :details="getFilteredDetails(index)" /> <p v-if="selfHasVotedOption(index)" class="results__option-subtitle"> {{ t('spreed','You voted') }} </p> @@ -443,6 +442,15 @@ export default { return false } }, + + getFilteredDetails(index) { + if (!this.details) { + return [] + } + return this.details.filter((item) => { + return item.optionId === index + }).slice(0, 8) + }, }, } </script> |