Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authormarco <marcoambrosini@pm.me>2022-02-22 13:45:09 +0300
committerJoas Schilling <coding@schilljs.com>2022-03-21 14:08:26 +0300
commit380c193396299d8a835b26342497db0d06d70c85 (patch)
treebfcd39d862473e9e00d6fc21854cf43c9c9d1c12 /src/store
parentd2f05c1485eeb5d292f10e153b0cf7543f30dae4 (diff)
Create a dedicated getter to know whether a message has detailed reaction or not
Signed-off-by: marco <marcoambrosini@pm.me>
Diffstat (limited to 'src/store')
-rw-r--r--src/store/messagesStore.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/store/messagesStore.js b/src/store/messagesStore.js
index a2cd87515..6fc60ae3f 100644
--- a/src/store/messagesStore.js
+++ b/src/store/messagesStore.js
@@ -195,13 +195,20 @@ const getters = {
return Object.keys(state.cancelPostNewMessage).length !== 0
},
+ hasReactionsDetails: (state) => (token, messageId) => {
+ const reactions = state.messages[token][messageId].reactions
+ // Check the first reaction to see if the reactions are detailed or not
+ return (typeof reactions[Object.keys(reactions)[0]]) === 'object'
+ },
+
/**
*
* @param {*} state The state object
+ * @param getters The getters
* @return {object} an object with the reactions (emojis) as keys and a number
* as value.
*/
- simplifiedReactions: (state) => (token, messageId) => {
+ simplifiedReactions: (state, getters) => (token, messageId) => {
const reactions = state.messages[token][messageId].reactions
// Return an empty object if there are no reactions for the message
@@ -209,10 +216,9 @@ const getters = {
return {}
}
- // Check the first reaction to see if the reactions are detailed or not
- const hasDetailedReactions = (typeof reactions[Object.keys(reactions)[0]]) === 'object'
+ const hasReactionsDetails = getters.hasReactionsDetails(token, messageId)
- if (!hasDetailedReactions) {
+ if (!hasReactionsDetails) {
return reactions
} else {
const simpleReactions = {}