@atlaskit/reactions 22.2.0 → 22.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.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/MockReactionsClient.js +1 -49
- package/dist/cjs/analytics/analytics.js +1 -40
- package/dist/cjs/analytics/index.js +0 -7
- package/dist/cjs/analytics/ufo.js +8 -20
- package/dist/cjs/client/ReactionServiceClient.js +2 -16
- package/dist/cjs/client/index.js +0 -1
- package/dist/cjs/components/Counter/Counter.js +10 -24
- package/dist/cjs/components/Counter/index.js +0 -6
- package/dist/cjs/components/Counter/styles.js +1 -3
- package/dist/cjs/components/EmojiButton/EmojiButton.js +3 -18
- package/dist/cjs/components/EmojiButton/index.js +0 -1
- package/dist/cjs/components/EmojiButton/styles.js +1 -2
- package/dist/cjs/components/FlashAnimation/FlashAnimation.js +1 -11
- package/dist/cjs/components/FlashAnimation/index.js +0 -1
- package/dist/cjs/components/FlashAnimation/styles.js +1 -3
- package/dist/cjs/components/Reaction/Reaction.js +23 -62
- package/dist/cjs/components/Reaction/index.js +0 -1
- package/dist/cjs/components/Reaction/styles.js +1 -4
- package/dist/cjs/components/ReactionDialog/ReactionView.js +6 -29
- package/dist/cjs/components/ReactionDialog/ReactionsDialog.js +19 -48
- package/dist/cjs/components/ReactionDialog/ReactionsList.js +18 -34
- package/dist/cjs/components/ReactionDialog/index.js +0 -1
- package/dist/cjs/components/ReactionDialog/styles.js +3 -13
- package/dist/cjs/components/ReactionPicker/ReactionPicker.js +41 -71
- package/dist/cjs/components/ReactionPicker/index.js +0 -1
- package/dist/cjs/components/ReactionPicker/styles.js +1 -4
- package/dist/cjs/components/ReactionTooltip/ReactionTooltip.js +13 -28
- package/dist/cjs/components/ReactionTooltip/index.js +0 -1
- package/dist/cjs/components/ReactionTooltip/styles.js +1 -3
- package/dist/cjs/components/Reactions/Reactions.js +48 -86
- package/dist/cjs/components/Reactions/index.js +0 -1
- package/dist/cjs/components/Reactions/styles.js +1 -2
- package/dist/cjs/components/Selector/Selector.js +12 -34
- package/dist/cjs/components/Selector/index.js +0 -6
- package/dist/cjs/components/Selector/styles.js +2 -5
- package/dist/cjs/components/ShowMore/ShowMore.js +5 -19
- package/dist/cjs/components/ShowMore/index.js +0 -1
- package/dist/cjs/components/ShowMore/styles.js +1 -4
- package/dist/cjs/components/Trigger/Trigger.js +6 -22
- package/dist/cjs/components/Trigger/index.js +0 -1
- package/dist/cjs/components/Trigger/styles.js +3 -13
- package/dist/cjs/components/UfoErrorBoundary/UfoErrorBoundary.js +1 -19
- package/dist/cjs/components/UfoErrorBoundary/index.js +0 -1
- package/dist/cjs/components/index.js +0 -5
- package/dist/cjs/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +2 -17
- package/dist/cjs/containers/ConnectedReactionPicker/index.js +0 -1
- package/dist/cjs/containers/ConnectedReactionsView/ConnectedReactionsView.js +17 -62
- package/dist/cjs/containers/ConnectedReactionsView/index.js +0 -1
- package/dist/cjs/containers/index.js +0 -4
- package/dist/cjs/hooks/index.js +0 -1
- package/dist/cjs/hooks/useClickAway.js +2 -5
- package/dist/cjs/i18n/cs.js +0 -1
- package/dist/cjs/i18n/da.js +0 -1
- package/dist/cjs/i18n/de.js +0 -1
- package/dist/cjs/i18n/en.js +0 -1
- package/dist/cjs/i18n/en_GB.js +0 -1
- package/dist/cjs/i18n/en_ZZ.js +0 -1
- package/dist/cjs/i18n/es.js +0 -1
- package/dist/cjs/i18n/et.js +0 -1
- package/dist/cjs/i18n/fi.js +0 -1
- package/dist/cjs/i18n/fr.js +0 -1
- package/dist/cjs/i18n/hu.js +0 -1
- package/dist/cjs/i18n/index.js +0 -30
- package/dist/cjs/i18n/it.js +0 -1
- package/dist/cjs/i18n/ja.js +0 -1
- package/dist/cjs/i18n/ko.js +0 -1
- package/dist/cjs/i18n/nb.js +0 -1
- package/dist/cjs/i18n/nl.js +0 -1
- package/dist/cjs/i18n/pl.js +0 -1
- package/dist/cjs/i18n/pt_BR.js +0 -1
- package/dist/cjs/i18n/pt_PT.js +0 -1
- package/dist/cjs/i18n/ru.js +0 -1
- package/dist/cjs/i18n/sk.js +0 -1
- package/dist/cjs/i18n/sv.js +0 -1
- package/dist/cjs/i18n/th.js +0 -1
- package/dist/cjs/i18n/tr.js +0 -1
- package/dist/cjs/i18n/uk.js +0 -1
- package/dist/cjs/i18n/vi.js +0 -1
- package/dist/cjs/i18n/zh.js +0 -1
- package/dist/cjs/i18n/zh_TW.js +0 -1
- package/dist/cjs/index.js +0 -6
- package/dist/cjs/shared/constants.js +5 -6
- package/dist/cjs/shared/i18n.js +0 -2
- package/dist/cjs/shared/index.js +0 -9
- package/dist/cjs/shared/utils.js +6 -25
- package/dist/cjs/store/MemoryReactionsStore.js +21 -74
- package/dist/cjs/store/ReactionConsumer.js +0 -28
- package/dist/cjs/store/batched.js +0 -6
- package/dist/cjs/store/index.js +0 -2
- package/dist/cjs/store/utils.js +0 -25
- package/dist/cjs/types/index.js +0 -1
- package/dist/cjs/types/reaction.js +0 -10
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/MockReactionsClient.js +7 -21
- package/dist/es2019/analytics/analytics.js +3 -9
- package/dist/es2019/analytics/ufo.js +11 -13
- package/dist/es2019/client/ReactionServiceClient.js +4 -13
- package/dist/es2019/components/Counter/Counter.js +5 -7
- package/dist/es2019/components/EmojiButton/EmojiButton.js +0 -3
- package/dist/es2019/components/FlashAnimation/FlashAnimation.js +1 -2
- package/dist/es2019/components/Reaction/Reaction.js +3 -12
- package/dist/es2019/components/Reaction/styles.js +1 -1
- package/dist/es2019/components/ReactionDialog/ReactionView.js +0 -4
- package/dist/es2019/components/ReactionDialog/ReactionsDialog.js +6 -15
- package/dist/es2019/components/ReactionDialog/ReactionsList.js +4 -3
- package/dist/es2019/components/ReactionDialog/styles.js +2 -5
- package/dist/es2019/components/ReactionPicker/ReactionPicker.js +14 -19
- package/dist/es2019/components/ReactionTooltip/ReactionTooltip.js +1 -2
- package/dist/es2019/components/Reactions/Reactions.js +16 -25
- package/dist/es2019/components/Selector/Selector.js +5 -11
- package/dist/es2019/components/Selector/styles.js +1 -1
- package/dist/es2019/components/ShowMore/ShowMore.js +1 -2
- package/dist/es2019/components/Trigger/Trigger.js +1 -5
- package/dist/es2019/components/UfoErrorBoundary/UfoErrorBoundary.js +0 -3
- package/dist/es2019/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +0 -4
- package/dist/es2019/containers/ConnectedReactionsView/ConnectedReactionsView.js +8 -20
- package/dist/es2019/hooks/useClickAway.js +3 -4
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/shared/constants.js +5 -5
- package/dist/es2019/shared/utils.js +7 -15
- package/dist/es2019/store/MemoryReactionsStore.js +36 -61
- package/dist/es2019/store/ReactionConsumer.js +1 -12
- package/dist/es2019/store/batched.js +0 -2
- package/dist/es2019/store/utils.js +4 -8
- package/dist/es2019/types/reaction.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/MockReactionsClient.js +1 -42
- package/dist/esm/analytics/analytics.js +1 -12
- package/dist/esm/analytics/ufo.js +11 -13
- package/dist/esm/client/ReactionServiceClient.js +2 -14
- package/dist/esm/components/Counter/Counter.js +12 -15
- package/dist/esm/components/EmojiButton/EmojiButton.js +2 -6
- package/dist/esm/components/FlashAnimation/FlashAnimation.js +1 -2
- package/dist/esm/components/Reaction/Reaction.js +23 -40
- package/dist/esm/components/Reaction/styles.js +1 -1
- package/dist/esm/components/ReactionDialog/ReactionView.js +5 -14
- package/dist/esm/components/ReactionDialog/ReactionsDialog.js +20 -35
- package/dist/esm/components/ReactionDialog/ReactionsList.js +17 -20
- package/dist/esm/components/ReactionDialog/styles.js +2 -5
- package/dist/esm/components/ReactionPicker/ReactionPicker.js +42 -52
- package/dist/esm/components/ReactionTooltip/ReactionTooltip.js +14 -16
- package/dist/esm/components/Reactions/Reactions.js +49 -62
- package/dist/esm/components/Selector/Selector.js +13 -22
- package/dist/esm/components/Selector/styles.js +1 -1
- package/dist/esm/components/ShowMore/ShowMore.js +6 -7
- package/dist/esm/components/Trigger/Trigger.js +7 -11
- package/dist/esm/components/Trigger/styles.js +3 -6
- package/dist/esm/components/UfoErrorBoundary/UfoErrorBoundary.js +1 -14
- package/dist/esm/containers/ConnectedReactionPicker/ConnectedReactionPicker.js +2 -9
- package/dist/esm/containers/ConnectedReactionsView/ConnectedReactionsView.js +17 -43
- package/dist/esm/hooks/useClickAway.js +3 -4
- package/dist/esm/index.js +2 -1
- package/dist/esm/shared/constants.js +5 -5
- package/dist/esm/shared/utils.js +7 -17
- package/dist/esm/store/MemoryReactionsStore.js +22 -78
- package/dist/esm/store/ReactionConsumer.js +0 -23
- package/dist/esm/store/batched.js +0 -4
- package/dist/esm/store/utils.js +0 -9
- package/dist/esm/types/reaction.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/components/ReactionDialog/styles.d.ts +1 -2
- package/package.json +2 -2
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
|
|
5
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
|
|
9
6
|
import { Analytics, UFO } from '../analytics';
|
|
10
7
|
import * as Types from '../types';
|
|
11
8
|
import { batch, batchByKey } from './batched';
|
|
@@ -14,33 +11,31 @@ import { isRealErrorFromService } from './utils';
|
|
|
14
11
|
import { SAMPLING_RATE_REACTIONS_RENDERED_EXP } from '../analytics/constants';
|
|
15
12
|
import { sampledReactionsRendered } from '../analytics/ufo';
|
|
16
13
|
import { extractErrorInfo } from '../analytics/analytics';
|
|
14
|
+
|
|
17
15
|
/**
|
|
18
16
|
* Set of all available UFO experiences relating to reaction element
|
|
19
17
|
*/
|
|
20
|
-
|
|
21
18
|
export var ufoExperiences = {
|
|
22
19
|
/**
|
|
23
20
|
* Experience when a reaction emoji gets added
|
|
24
21
|
*/
|
|
25
22
|
add: UFO.ReactionsAdd,
|
|
26
|
-
|
|
27
23
|
/**
|
|
28
24
|
* Experience when a reaction emoji gets removed/decrement
|
|
29
25
|
*/
|
|
30
26
|
remove: UFO.ReactionsRemove,
|
|
31
|
-
|
|
32
27
|
/**
|
|
33
28
|
* Experience when the list of reactions gets rendered with sampling
|
|
34
29
|
*/
|
|
35
30
|
render: function render(instanceId) {
|
|
36
31
|
return sampledReactionsRendered(instanceId);
|
|
37
32
|
},
|
|
38
|
-
|
|
39
33
|
/**
|
|
40
34
|
* Experience when a reaction details gets fetched
|
|
41
35
|
*/
|
|
42
36
|
fetchDetails: UFO.ReactionDetailsFetch
|
|
43
37
|
};
|
|
38
|
+
|
|
44
39
|
/**
|
|
45
40
|
* Optional metadata information in the store used in sending the API client requests
|
|
46
41
|
*/
|
|
@@ -49,56 +44,45 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
49
44
|
/**
|
|
50
45
|
* default initial store data
|
|
51
46
|
*/
|
|
47
|
+
|
|
52
48
|
function MemoryReactionsStore(client, state, metadata) {
|
|
53
49
|
var _this = this;
|
|
54
|
-
|
|
55
50
|
_classCallCheck(this, MemoryReactionsStore);
|
|
56
|
-
|
|
57
51
|
_defineProperty(this, "callbacks", []);
|
|
58
|
-
|
|
59
52
|
_defineProperty(this, "initialState", {
|
|
60
53
|
reactions: {},
|
|
61
54
|
flash: {}
|
|
62
55
|
});
|
|
63
|
-
|
|
64
56
|
_defineProperty(this, "setState", function (newState) {
|
|
65
57
|
_this.state = _objectSpread(_objectSpread({}, _this.state), newState);
|
|
66
|
-
|
|
67
58
|
_this.triggerOnChange();
|
|
68
59
|
});
|
|
69
|
-
|
|
70
60
|
_defineProperty(this, "triggerOnChange", batch(function () {
|
|
71
61
|
return _this.callbacks.forEach(function (callback) {
|
|
72
62
|
return callback(_this.state);
|
|
73
63
|
});
|
|
74
64
|
}));
|
|
75
|
-
|
|
76
65
|
_defineProperty(this, "setReactions", function (containerAri, ari, reactions) {
|
|
77
66
|
_this.setState({
|
|
78
67
|
reactions: _objectSpread(_objectSpread({}, _this.state.reactions), {}, _defineProperty({}, "".concat(containerAri, "|").concat(ari), reactions))
|
|
79
68
|
});
|
|
80
69
|
});
|
|
81
|
-
|
|
82
70
|
_defineProperty(this, "handleDetailedReactionResponse", function (detailedReaction) {
|
|
83
71
|
var containerAri = detailedReaction.containerAri,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
ari = detailedReaction.ari,
|
|
73
|
+
emojiId = detailedReaction.emojiId;
|
|
87
74
|
_this.withReaction(function (reaction) {
|
|
88
75
|
return _objectSpread(_objectSpread({}, reaction), {}, {
|
|
89
76
|
users: detailedReaction.users
|
|
90
77
|
});
|
|
91
78
|
})(containerAri, ari, emojiId);
|
|
92
79
|
});
|
|
93
|
-
|
|
94
80
|
_defineProperty(this, "flash", function (reaction) {
|
|
95
81
|
_this.setFlash(reaction.containerAri, reaction.ari, reaction.emojiId, true);
|
|
96
|
-
|
|
97
82
|
window.setTimeout(function () {
|
|
98
83
|
return _this.setFlash(reaction.containerAri, reaction.ari, reaction.emojiId, false);
|
|
99
84
|
}, 700);
|
|
100
85
|
});
|
|
101
|
-
|
|
102
86
|
_defineProperty(this, "optmisticUpdate", function (containerAri, ari, emojiId) {
|
|
103
87
|
return function (updater) {
|
|
104
88
|
_this.withReadyReaction(containerAri, ari)(function (reactionState) {
|
|
@@ -107,17 +91,14 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
107
91
|
if (reaction.emojiId === emojiId) {
|
|
108
92
|
found = true;
|
|
109
93
|
var updated = updater(reaction);
|
|
110
|
-
|
|
111
94
|
if (updated) {
|
|
112
95
|
return _objectSpread(_objectSpread({}, updated), {}, {
|
|
113
96
|
optimisticallyUpdated: true
|
|
114
97
|
});
|
|
115
98
|
}
|
|
116
99
|
}
|
|
117
|
-
|
|
118
100
|
return reaction;
|
|
119
101
|
});
|
|
120
|
-
|
|
121
102
|
if (!found) {
|
|
122
103
|
var updated = updater({
|
|
123
104
|
containerAri: containerAri,
|
|
@@ -126,30 +107,24 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
126
107
|
count: 0,
|
|
127
108
|
reacted: false
|
|
128
109
|
});
|
|
129
|
-
|
|
130
110
|
if (updated) {
|
|
131
111
|
reactions.push(_objectSpread(_objectSpread({}, updated), {}, {
|
|
132
112
|
optimisticallyUpdated: true
|
|
133
113
|
}));
|
|
134
114
|
}
|
|
135
115
|
}
|
|
136
|
-
|
|
137
116
|
return utils.readyState(reactions);
|
|
138
117
|
});
|
|
139
118
|
};
|
|
140
119
|
});
|
|
141
|
-
|
|
142
120
|
_defineProperty(this, "doAddReaction", function (reaction) {
|
|
143
121
|
var containerAri = reaction.containerAri,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
122
|
+
ari = reaction.ari,
|
|
123
|
+
emojiId = reaction.emojiId;
|
|
147
124
|
_this.optmisticUpdate(containerAri, ari, emojiId)(utils.addOne);
|
|
148
|
-
|
|
149
125
|
_this.flash(reaction);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
126
|
+
var exp = ufoExperiences.add.getInstance("".concat(ari, "|").concat(emojiId));
|
|
127
|
+
// ufo start reaction experience
|
|
153
128
|
exp.start();
|
|
154
129
|
exp.addMetadata({
|
|
155
130
|
source: 'MemoryReactionsStore',
|
|
@@ -158,18 +133,16 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
158
133
|
containerAri: containerAri,
|
|
159
134
|
emojiId: emojiId
|
|
160
135
|
});
|
|
161
|
-
|
|
162
136
|
_this.client.addReaction(containerAri, ari, emojiId, _this.metadata).then(function (_) {
|
|
163
137
|
if (_this.createAnalyticsEvent) {
|
|
164
138
|
Analytics.createAndFireSafe(_this.createAnalyticsEvent, Analytics.createRestSucceededEvent, 'addReaction');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
139
|
+
}
|
|
140
|
+
// ufo add reaction success
|
|
168
141
|
exp.success();
|
|
169
142
|
}).catch(function (error) {
|
|
170
143
|
if (isRealErrorFromService(error.code)) {
|
|
171
|
-
_this.createAnalyticsEvent && Analytics.createAndFireSafe(_this.createAnalyticsEvent, Analytics.createRestFailedEvent, 'addReaction', error.code);
|
|
172
|
-
|
|
144
|
+
_this.createAnalyticsEvent && Analytics.createAndFireSafe(_this.createAnalyticsEvent, Analytics.createRestFailedEvent, 'addReaction', error.code);
|
|
145
|
+
// ufo add reaction failure
|
|
173
146
|
exp.failure({
|
|
174
147
|
metadata: {
|
|
175
148
|
error: extractErrorInfo(error),
|
|
@@ -177,16 +150,16 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
177
150
|
}
|
|
178
151
|
});
|
|
179
152
|
}
|
|
180
|
-
|
|
181
153
|
return Promise.reject(error);
|
|
182
154
|
});
|
|
183
155
|
});
|
|
184
|
-
|
|
185
156
|
_defineProperty(this, "doRemoveReaction", function (reaction) {
|
|
186
157
|
var containerAri = reaction.containerAri,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
var exp = ufoExperiences.remove.getInstance("".concat(ari, "|").concat(emojiId));
|
|
158
|
+
ari = reaction.ari,
|
|
159
|
+
emojiId = reaction.emojiId;
|
|
160
|
+
var exp = ufoExperiences.remove.getInstance("".concat(ari, "|").concat(emojiId));
|
|
161
|
+
|
|
162
|
+
// ufo start reaction experience
|
|
190
163
|
|
|
191
164
|
exp.start();
|
|
192
165
|
exp.addMetadata({
|
|
@@ -196,9 +169,7 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
196
169
|
containerAri: containerAri,
|
|
197
170
|
emojiId: emojiId
|
|
198
171
|
});
|
|
199
|
-
|
|
200
172
|
_this.optmisticUpdate(containerAri, ari, emojiId)(utils.removeOne);
|
|
201
|
-
|
|
202
173
|
_this.client.deleteReaction(containerAri, ari, emojiId, _this.metadata).then(function (_) {
|
|
203
174
|
// ufo add reaction success
|
|
204
175
|
exp.success();
|
|
@@ -212,19 +183,17 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
212
183
|
});
|
|
213
184
|
});
|
|
214
185
|
});
|
|
215
|
-
|
|
216
186
|
_defineProperty(this, "setCreateAnalyticsEvent", function (createAnalyticsEvent) {
|
|
217
187
|
_this.createAnalyticsEvent = createAnalyticsEvent;
|
|
218
188
|
});
|
|
219
|
-
|
|
220
189
|
_defineProperty(this, "getReactions", batchByKey(function (containerAri, aris) {
|
|
221
190
|
/**
|
|
222
191
|
* TODO:
|
|
223
192
|
* All reactions are usually fetched in a single call to reactions-service. Need to check why "getReactions" gets called randomly 1-2 times everytime on each fetch request despite using same containerAri.
|
|
224
193
|
*/
|
|
225
194
|
var sampledExp = ufoExperiences.render(containerAri);
|
|
226
|
-
var arisArr = aris.reduce(utils.flattenAris);
|
|
227
|
-
|
|
195
|
+
var arisArr = aris.reduce(utils.flattenAris);
|
|
196
|
+
// ufo start reaction experience
|
|
228
197
|
sampledExp.start({
|
|
229
198
|
samplingRate: SAMPLING_RATE_REACTIONS_RENDERED_EXP
|
|
230
199
|
});
|
|
@@ -234,27 +203,22 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
234
203
|
containerAri: containerAri,
|
|
235
204
|
aris: arisArr.join(',')
|
|
236
205
|
});
|
|
237
|
-
|
|
238
206
|
_this.client.getReactions(containerAri, arisArr).then(function (value) {
|
|
239
207
|
Object.keys(value).map(function (ari) {
|
|
240
208
|
var reactionsState = _this.getReactionsState(containerAri, ari);
|
|
241
|
-
|
|
242
209
|
var reactions = reactionsState && reactionsState.status === Types.ReactionStatus.ready ? reactionsState.reactions : undefined;
|
|
243
|
-
|
|
244
210
|
_this.setReactions(containerAri, ari, utils.readyState(value[ari].sort(utils.getReactionsSortFunction(reactions))));
|
|
245
211
|
});
|
|
246
212
|
}).then(function () {
|
|
247
213
|
if (_this.createAnalyticsEvent) {
|
|
248
214
|
Analytics.createAndFireSafe(_this.createAnalyticsEvent, Analytics.createRestSucceededEvent, 'getReactions');
|
|
249
215
|
}
|
|
250
|
-
|
|
251
216
|
sampledExp.success();
|
|
252
217
|
}).catch(function (error) {
|
|
253
218
|
if (isRealErrorFromService(error.code)) {
|
|
254
219
|
if (_this.createAnalyticsEvent) {
|
|
255
220
|
Analytics.createAndFireSafe(_this.createAnalyticsEvent, Analytics.createRestFailedEvent, 'getReactions');
|
|
256
221
|
}
|
|
257
|
-
|
|
258
222
|
sampledExp.failure({
|
|
259
223
|
metadata: {
|
|
260
224
|
error: extractErrorInfo(error),
|
|
@@ -262,26 +226,20 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
262
226
|
}
|
|
263
227
|
});
|
|
264
228
|
}
|
|
265
|
-
|
|
266
229
|
var reactionsState = arisArr.reduce(function (acc, ari) {
|
|
267
230
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, "".concat(containerAri, "|").concat(ari), {
|
|
268
231
|
reactions: [],
|
|
269
232
|
status: Types.ReactionStatus.error
|
|
270
233
|
}));
|
|
271
234
|
}, {});
|
|
272
|
-
|
|
273
235
|
_this.setState(_objectSpread(_objectSpread({}, _this.state), {}, {
|
|
274
236
|
reactions: _objectSpread(_objectSpread({}, _this.state.reactions), reactionsState)
|
|
275
237
|
}));
|
|
276
|
-
|
|
277
238
|
return Promise.reject(error);
|
|
278
239
|
});
|
|
279
240
|
}));
|
|
280
|
-
|
|
281
241
|
_defineProperty(this, "toggleReaction", this.withReaction(this.doRemoveReaction, this.doAddReaction));
|
|
282
|
-
|
|
283
242
|
_defineProperty(this, "addReaction", this.withReaction(this.flash, this.doAddReaction));
|
|
284
|
-
|
|
285
243
|
_defineProperty(this, "getDetailedReaction", function (containerAri, ari, emojiId) {
|
|
286
244
|
var exp = ufoExperiences.fetchDetails.getInstance("".concat(ari, "|").concat(emojiId));
|
|
287
245
|
exp.start();
|
|
@@ -292,11 +250,9 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
292
250
|
containerAri: containerAri,
|
|
293
251
|
emojiId: emojiId
|
|
294
252
|
});
|
|
295
|
-
|
|
296
253
|
_this.client.getDetailedReaction(containerAri, ari, emojiId).then(function (summary) {
|
|
297
254
|
// ufo get reaction details success
|
|
298
255
|
exp.success();
|
|
299
|
-
|
|
300
256
|
_this.handleDetailedReactionResponse(summary);
|
|
301
257
|
}).catch(function (error) {
|
|
302
258
|
// ufo get reaction details failure
|
|
@@ -308,31 +264,26 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
308
264
|
});
|
|
309
265
|
});
|
|
310
266
|
});
|
|
311
|
-
|
|
312
267
|
_defineProperty(this, "getState", function () {
|
|
313
268
|
return _this.state;
|
|
314
269
|
});
|
|
315
|
-
|
|
316
270
|
_defineProperty(this, "onChange", function (callback) {
|
|
317
271
|
_this.callbacks.push(callback);
|
|
318
272
|
});
|
|
319
|
-
|
|
320
273
|
_defineProperty(this, "removeOnChangeListener", function (toRemove) {
|
|
321
274
|
_this.callbacks = _this.callbacks.filter(function (callback) {
|
|
322
275
|
return callback !== toRemove;
|
|
323
276
|
});
|
|
324
277
|
});
|
|
325
|
-
|
|
326
278
|
this.client = client;
|
|
327
279
|
this.state = state !== null && state !== void 0 ? state : this.initialState;
|
|
328
280
|
this.metadata = metadata;
|
|
329
281
|
}
|
|
282
|
+
|
|
330
283
|
/**
|
|
331
284
|
* Update the store state data with a new data
|
|
332
285
|
* @param newState new store data
|
|
333
286
|
*/
|
|
334
|
-
|
|
335
|
-
|
|
336
287
|
_createClass(MemoryReactionsStore, [{
|
|
337
288
|
key: "getReactionsState",
|
|
338
289
|
value: function getReactionsState(containerAri, ari) {
|
|
@@ -361,19 +312,17 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
361
312
|
*/
|
|
362
313
|
function withReadyReaction(containerAri, ari) {
|
|
363
314
|
var _this2 = this;
|
|
364
|
-
|
|
365
315
|
return function (updater) {
|
|
366
316
|
var reactionsState = _this2.getReactionsState(containerAri, ari);
|
|
367
|
-
|
|
368
317
|
if (reactionsState && reactionsState.status === Types.ReactionStatus.ready) {
|
|
369
318
|
var updated = updater(reactionsState);
|
|
370
|
-
|
|
371
319
|
if (updated) {
|
|
372
320
|
_this2.setReactions(containerAri, ari, updated);
|
|
373
321
|
}
|
|
374
322
|
}
|
|
375
323
|
};
|
|
376
324
|
}
|
|
325
|
+
|
|
377
326
|
/**
|
|
378
327
|
* Utility function to help execute actions with a reaction. It handles reaction discovery
|
|
379
328
|
* and branching between reacted and not reacted.
|
|
@@ -387,12 +336,10 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
387
336
|
* A function that will execute the correct callback to the triple containerAri, ari and
|
|
388
337
|
* emojiId. If some state is returned, the new state will be applied.
|
|
389
338
|
*/
|
|
390
|
-
|
|
391
339
|
}, {
|
|
392
340
|
key: "withReaction",
|
|
393
341
|
value: function withReaction(reactedCallback, notReactedCallback) {
|
|
394
342
|
var _this3 = this;
|
|
395
|
-
|
|
396
343
|
return function (containerAri, ari, emojiId) {
|
|
397
344
|
_this3.withReadyReaction(containerAri, ari)(function (reactionsState) {
|
|
398
345
|
var reaction = reactionsState.reactions.find(utils.byEmojiId(emojiId)) || {
|
|
@@ -404,16 +351,13 @@ export var MemoryReactionsStore = /*#__PURE__*/function () {
|
|
|
404
351
|
};
|
|
405
352
|
var callback = reaction.reacted || !notReactedCallback ? reactedCallback : notReactedCallback;
|
|
406
353
|
var updatedReaction = callback(reaction);
|
|
407
|
-
|
|
408
354
|
if (updatedReaction && !(updatedReaction instanceof Function)) {
|
|
409
355
|
return utils.readyState(reactionsState.reactions.map(utils.updateByEmojiId(emojiId, updatedReaction)));
|
|
410
356
|
}
|
|
411
|
-
|
|
412
357
|
return;
|
|
413
358
|
});
|
|
414
359
|
};
|
|
415
360
|
}
|
|
416
361
|
}]);
|
|
417
|
-
|
|
418
362
|
return MemoryReactionsStore;
|
|
419
363
|
}();
|
|
@@ -7,67 +7,50 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
-
|
|
11
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
|
|
13
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
-
|
|
15
12
|
import React from 'react';
|
|
16
|
-
|
|
17
13
|
/**
|
|
18
14
|
* A custom mapper class that takes the store instance and mapper functions "mapStateToProps" and "mapActionsToProps" to return the renderProps pattern as a child component
|
|
19
15
|
* @deprecated please avoid using this class as it will be removed in a future release
|
|
20
16
|
*/
|
|
21
17
|
export var ReactionConsumer = /*#__PURE__*/function (_React$PureComponent) {
|
|
22
18
|
_inherits(ReactionConsumer, _React$PureComponent);
|
|
23
|
-
|
|
24
19
|
var _super = _createSuper(ReactionConsumer);
|
|
25
|
-
|
|
26
20
|
function ReactionConsumer(props) {
|
|
27
21
|
var _this;
|
|
28
|
-
|
|
29
22
|
_classCallCheck(this, ReactionConsumer);
|
|
30
|
-
|
|
31
23
|
_this = _super.call(this, props);
|
|
32
|
-
|
|
33
24
|
_defineProperty(_assertThisInitialized(_this), "getPropsFromActions", function (actions) {
|
|
34
25
|
var mapActionsToProps = _this.props.mapActionsToProps;
|
|
35
|
-
|
|
36
26
|
if (mapActionsToProps) {
|
|
37
27
|
if (!_this.previousActions || !_this.propsFromActions || _this.previousActions !== actions) {
|
|
38
28
|
_this.propsFromActions = mapActionsToProps(actions);
|
|
39
29
|
}
|
|
40
30
|
}
|
|
41
|
-
|
|
42
31
|
_this.previousActions = actions;
|
|
43
32
|
return _this.propsFromActions;
|
|
44
33
|
});
|
|
45
|
-
|
|
46
34
|
_defineProperty(_assertThisInitialized(_this), "getPropsFromState", function (state) {
|
|
47
35
|
var mapStateToProps = _this.props.mapStateToProps;
|
|
48
36
|
return mapStateToProps ? mapStateToProps(state) : undefined;
|
|
49
37
|
});
|
|
50
|
-
|
|
51
38
|
_defineProperty(_assertThisInitialized(_this), "handleOnChange", function () {
|
|
52
39
|
_this.forceUpdate();
|
|
53
40
|
});
|
|
54
|
-
|
|
55
41
|
_this.state = {
|
|
56
42
|
store: undefined
|
|
57
43
|
};
|
|
58
44
|
return _this;
|
|
59
45
|
}
|
|
60
|
-
|
|
61
46
|
_createClass(ReactionConsumer, [{
|
|
62
47
|
key: "componentDidMount",
|
|
63
48
|
value: function componentDidMount() {
|
|
64
49
|
var _this2 = this;
|
|
65
|
-
|
|
66
50
|
Promise.resolve(this.props.store).then(function (store) {
|
|
67
51
|
_this2.setState({
|
|
68
52
|
store: store
|
|
69
53
|
});
|
|
70
|
-
|
|
71
54
|
store.onChange(_this2.handleOnChange);
|
|
72
55
|
});
|
|
73
56
|
}
|
|
@@ -82,7 +65,6 @@ export var ReactionConsumer = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
82
65
|
if (this.state.store) {
|
|
83
66
|
this.state.store.removeOnChangeListener(this.handleOnChange);
|
|
84
67
|
}
|
|
85
|
-
|
|
86
68
|
case 1:
|
|
87
69
|
case "end":
|
|
88
70
|
return _context.stop();
|
|
@@ -90,27 +72,22 @@ export var ReactionConsumer = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
90
72
|
}
|
|
91
73
|
}, _callee, this);
|
|
92
74
|
}));
|
|
93
|
-
|
|
94
75
|
function componentWillUnmount() {
|
|
95
76
|
return _componentWillUnmount.apply(this, arguments);
|
|
96
77
|
}
|
|
97
|
-
|
|
98
78
|
return componentWillUnmount;
|
|
99
79
|
}()
|
|
100
80
|
/**
|
|
101
81
|
* Get the actions the child component might need to dispatch from its props
|
|
102
82
|
*/
|
|
103
|
-
|
|
104
83
|
}, {
|
|
105
84
|
key: "render",
|
|
106
85
|
value: function render() {
|
|
107
86
|
if (!this.state.store) {
|
|
108
87
|
return null;
|
|
109
88
|
}
|
|
110
|
-
|
|
111
89
|
return this.props.children(Object.assign({}, this.getPropsFromState(this.state.store.getState()), this.getPropsFromActions(this.state.store)));
|
|
112
90
|
}
|
|
113
91
|
}]);
|
|
114
|
-
|
|
115
92
|
return ReactionConsumer;
|
|
116
93
|
}(React.PureComponent);
|
|
@@ -8,11 +8,9 @@ export function batch(callback) {
|
|
|
8
8
|
});
|
|
9
9
|
calls = [];
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13
12
|
args[_key] = arguments[_key];
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
calls.push(args);
|
|
17
15
|
};
|
|
18
16
|
}
|
|
@@ -26,11 +24,9 @@ export function batchByKey(callback) {
|
|
|
26
24
|
});
|
|
27
25
|
calls[key] = [];
|
|
28
26
|
}
|
|
29
|
-
|
|
30
27
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
31
28
|
args[_key2 - 1] = arguments[_key2];
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
calls[key].push(args);
|
|
35
31
|
};
|
|
36
32
|
}
|
package/dist/esm/store/utils.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
import { ReactionStatus } from '../types';
|
|
8
|
-
|
|
9
5
|
var compareEmojiId = function compareEmojiId(l, r) {
|
|
10
6
|
return l.localeCompare(r);
|
|
11
7
|
};
|
|
12
|
-
|
|
13
8
|
var sortByRelevance = function sortByRelevance(a, b) {
|
|
14
9
|
if (a.count > b.count) {
|
|
15
10
|
return -1;
|
|
@@ -19,23 +14,19 @@ var sortByRelevance = function sortByRelevance(a, b) {
|
|
|
19
14
|
return compareEmojiId(a.emojiId, b.emojiId);
|
|
20
15
|
}
|
|
21
16
|
};
|
|
22
|
-
|
|
23
17
|
var sortByPreviousPosition = function sortByPreviousPosition(reactions) {
|
|
24
18
|
var indexes = reactions.reduce(function (map, reaction, index) {
|
|
25
19
|
map[reaction.emojiId] = index;
|
|
26
20
|
return map;
|
|
27
21
|
}, {});
|
|
28
|
-
|
|
29
22
|
var getPosition = function getPosition(_ref) {
|
|
30
23
|
var emojiId = _ref.emojiId;
|
|
31
24
|
return indexes[emojiId] === undefined ? reactions.length : indexes[emojiId];
|
|
32
25
|
};
|
|
33
|
-
|
|
34
26
|
return function (a, b) {
|
|
35
27
|
return getPosition(a) - getPosition(b);
|
|
36
28
|
};
|
|
37
29
|
};
|
|
38
|
-
|
|
39
30
|
export var readyState = function readyState(reactions) {
|
|
40
31
|
return {
|
|
41
32
|
status: ReactionStatus.ready,
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
* Condition of the reaction when gets loaded from the store
|
|
39
39
|
*/
|
|
40
40
|
export var ReactionStatus;
|
|
41
|
+
|
|
41
42
|
/**
|
|
42
43
|
* state in which the reaction is at
|
|
43
44
|
*/
|
|
44
|
-
|
|
45
45
|
(function (ReactionStatus) {
|
|
46
46
|
ReactionStatus["ready"] = "READY";
|
|
47
47
|
ReactionStatus["loading"] = "LOADING";
|
package/dist/esm/version.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ThemeIds } from '@atlaskit/tokens';
|
|
2
1
|
export declare const containerStyle: (reactionsBorderWidth: number) => import("@emotion/react").SerializedStyles;
|
|
3
2
|
export declare const titleStyle: import("@emotion/react").SerializedStyles;
|
|
4
3
|
export declare const counterStyle: (isSelected: boolean) => import("@emotion/react").SerializedStyles;
|
|
5
|
-
export declare const customTabWrapper: (isSelected: boolean, selectedEmojiId: string, theme
|
|
4
|
+
export declare const customTabWrapper: (isSelected: boolean, selectedEmojiId: string, theme?: "auto" | "dark" | "light" | undefined) => import("@emotion/react").SerializedStyles;
|
|
6
5
|
export declare const navigationContainerStyle: import("@emotion/react").SerializedStyles;
|
|
7
6
|
export declare const reactionViewStyle: import("@emotion/react").SerializedStyles;
|
|
8
7
|
export declare const userListStyle: import("@emotion/react").SerializedStyles;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/reactions",
|
|
3
|
-
"version": "22.2.
|
|
3
|
+
"version": "22.2.1",
|
|
4
4
|
"description": "Reactions component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@atlaskit/spinner": "^15.3.0",
|
|
40
40
|
"@atlaskit/tabs": "^13.2.12",
|
|
41
41
|
"@atlaskit/theme": "^12.2.0",
|
|
42
|
-
"@atlaskit/tokens": "^0.
|
|
42
|
+
"@atlaskit/tokens": "^1.0.0",
|
|
43
43
|
"@atlaskit/tooltip": "^17.6.0",
|
|
44
44
|
"@atlaskit/ufo": "^0.1.0",
|
|
45
45
|
"@atlaskit/util-service-support": "^6.1.0",
|