Skip to content

Commit

Permalink
fix(Reactions): Add a safeguard to plain reactions
Browse files Browse the repository at this point in the history
Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Feb 16, 2024
1 parent 33860bc commit e65c1b5
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<template>
<!-- reactions buttons and popover with details -->
<div class="reactions-wrapper">
<div v-if="reactionsCount && reactionsSorted" class="reactions-wrapper">
<NcPopover v-for="reaction in reactionsSorted"
:key="reaction"
:delay="200"
Expand Down Expand Up @@ -175,11 +175,14 @@ export default {
},

reactionsSorted() {
return this.detailedReactions
? Object.keys(this.detailedReactions)
if (this.detailedReactions) {
return Object.keys(this.detailedReactions)
.sort((a, b) => this.detailedReactions[b].length - this.detailedReactions[a].length)
: Object.keys(this.plainReactions)
} else if (this.plainReactions) {
return Object.keys(this.plainReactions)
.sort((a, b) => this.plainReactions[b] - this.plainReactions[a])
}
return undefined
},

/**
Expand Down Expand Up @@ -243,6 +246,9 @@ export default {
},

reactionsCount(reaction) {
if (this.detailedReactions || this.plainReactions) {
return undefined
}
return this.detailedReactions
? this.detailedReactions[reaction]?.length
: this.plainReactions[reaction]
Expand Down

0 comments on commit e65c1b5

Please sign in to comment.