@nodebb/nodebb-plugin-reactions 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/library.js +35 -31
  2. package/package.json +1 -1
package/library.js CHANGED
@@ -119,22 +119,24 @@ ReactionsPlugin.getPostReactions = async function (data) {
119
119
  const reactionSetToUsersMap = await getReactionSetsUidsMap(reactionSets);
120
120
 
121
121
  for (const post of data.posts) {
122
- post.maxReactionsReached = pidToIsMaxReactionsReachedMap.get(post.pid);
123
- post.reactions = [];
124
-
125
- const reactions = pidToReactionsMap.get(post.pid);
126
- if (reactions) {
127
- for (const reaction of reactions) {
128
- const reactionSet = `pid:${post.pid}:reaction:${reaction}`;
129
- const uids = reactionSetToUsersMap.get(reactionSet);
130
- if (Array.isArray(uids)) {
131
- post.reactions.push({
132
- pid: post.pid,
133
- reacted: uids.includes(String(data.uid)),
134
- reaction,
135
- reactionImage: parse(reaction),
136
- reactionCount: uids.length,
137
- });
122
+ if (post) {
123
+ post.maxReactionsReached = pidToIsMaxReactionsReachedMap.get(post.pid);
124
+ post.reactions = [];
125
+
126
+ const reactions = pidToReactionsMap.get(post.pid);
127
+ if (reactions) {
128
+ for (const reaction of reactions) {
129
+ const reactionSet = `pid:${post.pid}:reaction:${reaction}`;
130
+ const uids = reactionSetToUsersMap.get(reactionSet);
131
+ if (Array.isArray(uids)) {
132
+ post.reactions.push({
133
+ pid: post.pid,
134
+ reacted: uids.includes(String(data.uid)),
135
+ reaction,
136
+ reactionImage: parse(reaction),
137
+ reactionCount: uids.length,
138
+ });
139
+ }
138
140
  }
139
141
  }
140
142
  }
@@ -179,21 +181,23 @@ ReactionsPlugin.getMessageReactions = async function (data) {
179
181
  const reactionSetToUsersMap = await getReactionSetsUidsMap(reactionSets);
180
182
 
181
183
  for (const msg of data.messages) {
182
- msg.maxReactionsReached = midToIsMaxReactionsReachedMap.get(msg.mid);
183
- msg.reactions = [];
184
- const reactions = midToReactionsMap.get(msg.mid);
185
- if (reactions) {
186
- for (const reaction of reactions) {
187
- const reactionSet = `mid:${msg.mid}:reaction:${reaction}`;
188
- const uids = reactionSetToUsersMap.get(reactionSet);
189
- if (Array.isArray(uids)) {
190
- msg.reactions.push({
191
- mid: msg.mid,
192
- reacted: uids.includes(String(data.uid)),
193
- reaction,
194
- reactionImage: parse(reaction),
195
- reactionCount: uids.length,
196
- });
184
+ if (msg) {
185
+ msg.maxReactionsReached = midToIsMaxReactionsReachedMap.get(msg.mid);
186
+ msg.reactions = [];
187
+ const reactions = midToReactionsMap.get(msg.mid);
188
+ if (reactions) {
189
+ for (const reaction of reactions) {
190
+ const reactionSet = `mid:${msg.mid}:reaction:${reaction}`;
191
+ const uids = reactionSetToUsersMap.get(reactionSet);
192
+ if (Array.isArray(uids)) {
193
+ msg.reactions.push({
194
+ mid: msg.mid,
195
+ reacted: uids.includes(String(data.uid)),
196
+ reaction,
197
+ reactionImage: parse(reaction),
198
+ reactionCount: uids.length,
199
+ });
200
+ }
197
201
  }
198
202
  }
199
203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodebb/nodebb-plugin-reactions",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "nbbpm": {
5
5
  "compatibility": "^3.6.0"
6
6
  },