@amityco/ts-sdk 6.5.4-984df54.0 → 6.5.4

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.
package/dist/index.cjs.js CHANGED
@@ -96,8 +96,8 @@ const PostContentType = Object.freeze({
96
96
 
97
97
  function getVersion() {
98
98
  try {
99
- // the string ''v6.5.3-cjs'' should be replaced by actual value by @rollup/plugin-replace
100
- return 'v6.5.3-cjs';
99
+ // the string ''v6.5.4-cjs'' should be replaced by actual value by @rollup/plugin-replace
100
+ return 'v6.5.4-cjs';
101
101
  }
102
102
  catch (error) {
103
103
  return '__dev__';
@@ -27067,21 +27067,21 @@ const rebuildPayload = (payload, payloadKey, myReactions) => {
27067
27067
  };
27068
27068
  /** @hidden */
27069
27069
  const prepareReactionPayloadFormEvent = (event, payload) => {
27070
- if (getActiveClient().userId !== payload.reactor.userId) {
27071
- return payload;
27072
- }
27073
27070
  const eventPrefix = event.split('.')[0]; // 'post' | 'comment'
27074
27071
  const eventSuffix = event.split('.')[1]; // 'addReaction' | 'removeReaction'
27075
- let myReactions;
27076
- const cachedMyReactions = getMyReactionsInCache(payload, eventPrefix);
27072
+ let myReactions = getMyReactionsInCache(payload, eventPrefix);
27077
27073
  if (eventSuffix === 'addReaction') {
27078
- myReactions = [...cachedMyReactions, payload.reactor.reactionName];
27074
+ if (!myReactions.includes(payload.reactor.reactionName)) {
27075
+ myReactions.push(payload.reactor.reactionName);
27076
+ }
27079
27077
  }
27080
27078
  else if (eventSuffix === 'removeReaction') {
27081
- myReactions = cachedMyReactions.filter(reaction => reaction !== payload.reactor.reactionName);
27079
+ if (getActiveClient().userId === payload.reactor.userId) {
27080
+ myReactions = myReactions.filter(reaction => reaction !== payload.reactor.reactionName);
27081
+ }
27082
27082
  }
27083
27083
  else {
27084
- throw new Error(`Unknown event type`);
27084
+ throw new Error(`Unknown event type: ${eventSuffix}`);
27085
27085
  }
27086
27086
  return rebuildPayload(payload, `${eventPrefix}s`, myReactions);
27087
27087
  };
package/dist/index.esm.js CHANGED
@@ -82,8 +82,8 @@ const PostContentType = Object.freeze({
82
82
 
83
83
  function getVersion() {
84
84
  try {
85
- // the string ''v6.5.3-esm'' should be replaced by actual value by @rollup/plugin-replace
86
- return 'v6.5.3-esm';
85
+ // the string ''v6.5.4-esm'' should be replaced by actual value by @rollup/plugin-replace
86
+ return 'v6.5.4-esm';
87
87
  }
88
88
  catch (error) {
89
89
  return '__dev__';
@@ -27053,21 +27053,21 @@ const rebuildPayload = (payload, payloadKey, myReactions) => {
27053
27053
  };
27054
27054
  /** @hidden */
27055
27055
  const prepareReactionPayloadFormEvent = (event, payload) => {
27056
- if (getActiveClient().userId !== payload.reactor.userId) {
27057
- return payload;
27058
- }
27059
27056
  const eventPrefix = event.split('.')[0]; // 'post' | 'comment'
27060
27057
  const eventSuffix = event.split('.')[1]; // 'addReaction' | 'removeReaction'
27061
- let myReactions;
27062
- const cachedMyReactions = getMyReactionsInCache(payload, eventPrefix);
27058
+ let myReactions = getMyReactionsInCache(payload, eventPrefix);
27063
27059
  if (eventSuffix === 'addReaction') {
27064
- myReactions = [...cachedMyReactions, payload.reactor.reactionName];
27060
+ if (!myReactions.includes(payload.reactor.reactionName)) {
27061
+ myReactions.push(payload.reactor.reactionName);
27062
+ }
27065
27063
  }
27066
27064
  else if (eventSuffix === 'removeReaction') {
27067
- myReactions = cachedMyReactions.filter(reaction => reaction !== payload.reactor.reactionName);
27065
+ if (getActiveClient().userId === payload.reactor.userId) {
27066
+ myReactions = myReactions.filter(reaction => reaction !== payload.reactor.reactionName);
27067
+ }
27068
27068
  }
27069
27069
  else {
27070
- throw new Error(`Unknown event type`);
27070
+ throw new Error(`Unknown event type: ${eventSuffix}`);
27071
27071
  }
27072
27072
  return rebuildPayload(payload, `${eventPrefix}s`, myReactions);
27073
27073
  };