stream-chat-react 10.10.2 → 10.11.0
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/browser.full-bundle.js +68 -39
- package/dist/browser.full-bundle.js.map +1 -1
- package/dist/browser.full-bundle.min.js +5 -5
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/components/Message/MessageSimple.d.ts.map +1 -1
- package/dist/components/Message/MessageSimple.js +10 -3
- package/dist/components/Message/hooks/useReactionHandler.d.ts.map +1 -1
- package/dist/components/Message/hooks/useReactionHandler.js +17 -21
- package/dist/components/MessageInput/CooldownTimer.js +1 -1
- package/dist/components/MessageInput/hooks/useCooldownTimer.d.ts.map +1 -1
- package/dist/components/MessageInput/hooks/useCooldownTimer.js +5 -2
- package/dist/context/MessageContext.d.ts +3 -1
- package/dist/context/MessageContext.d.ts.map +1 -1
- package/dist/context/TranslationContext.d.ts +1 -1
- package/dist/context/TranslationContext.d.ts.map +1 -1
- package/dist/i18n/Streami18n.d.ts +9 -3
- package/dist/i18n/Streami18n.d.ts.map +1 -1
- package/dist/i18n/Streami18n.js +18 -11
- package/dist/index.cjs.js +54 -39
- package/dist/index.cjs.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageSimple.d.ts","sourceRoot":"","sources":["../../../src/components/Message/MessageSimple.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,mBAAmB,EAAqB,MAAM,8BAA8B,CAAC;AAEtF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"MessageSimple.d.ts","sourceRoot":"","sources":["../../../src/components/Message/MessageSimple.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,mBAAmB,EAAqB,MAAM,8BAA8B,CAAC;AAEtF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AA4LnE;;GAEG;AACH,eAAO,MAAM,aAAa,4JAQzB,CAAC"}
|
|
@@ -31,6 +31,13 @@ var MessageSimpleWithContext = function (props) {
|
|
|
31
31
|
if (message.deleted_at || message.type === 'deleted') {
|
|
32
32
|
return React.createElement(MessageDeleted, { message: message });
|
|
33
33
|
}
|
|
34
|
+
/** FIXME: isReactionEnabled should be removed with next major version and a proper centralized permissions logic should be put in place
|
|
35
|
+
* With the current permissions implementation it would be sth like:
|
|
36
|
+
* const messageActions = getMessageActions();
|
|
37
|
+
* const canReact = messageActions.includes(MESSAGE_ACTIONS.react);
|
|
38
|
+
*/
|
|
39
|
+
var canReact = isReactionEnabled;
|
|
40
|
+
var canShowReactions = hasReactions;
|
|
34
41
|
var showMetadata = !groupedByUser || endOfGroup;
|
|
35
42
|
var showReplyCountButton = !threadList && !!message.reply_count;
|
|
36
43
|
var allowRetry = message.status === 'failed' && message.errorStatusCode !== 403;
|
|
@@ -40,7 +47,7 @@ var MessageSimpleWithContext = function (props) {
|
|
|
40
47
|
'pinned-message': message.pinned,
|
|
41
48
|
'str-chat__message--has-attachment': hasAttachment,
|
|
42
49
|
'str-chat__message--highlighted': highlighted,
|
|
43
|
-
'str-chat__message--with-reactions str-chat__message-with-thread-link':
|
|
50
|
+
'str-chat__message--with-reactions str-chat__message-with-thread-link': canShowReactions,
|
|
44
51
|
'str-chat__message-send-can-be-retried': (message === null || message === void 0 ? void 0 : message.status) === 'failed' && (message === null || message === void 0 ? void 0 : message.errorStatusCode) !== 403,
|
|
45
52
|
'str-chat__virtual-message__wrapper--end': endOfGroup,
|
|
46
53
|
'str-chat__virtual-message__wrapper--first': firstOfGroup,
|
|
@@ -57,8 +64,8 @@ var MessageSimpleWithContext = function (props) {
|
|
|
57
64
|
}), "data-testid": 'message-inner', onClick: allowRetry ? function () { return handleRetry(message); } : undefined, onKeyUp: allowRetry ? function () { return handleRetry(message); } : undefined },
|
|
58
65
|
React.createElement(MessageOptions, null),
|
|
59
66
|
React.createElement("div", { className: 'str-chat__message-reactions-host' },
|
|
60
|
-
|
|
61
|
-
showDetailedReactions &&
|
|
67
|
+
canShowReactions && React.createElement(ReactionsList, { reverse: true }),
|
|
68
|
+
showDetailedReactions && canReact && React.createElement(ReactionSelector, { ref: reactionSelectorRef })),
|
|
62
69
|
React.createElement("div", { className: 'str-chat__message-bubble' },
|
|
63
70
|
((_a = message.attachments) === null || _a === void 0 ? void 0 : _a.length) && !message.quoted_message ? (React.createElement(Attachment, { actionHandler: handleAction, attachments: message.attachments })) : null,
|
|
64
71
|
React.createElement(MessageText, { message: message, renderText: renderText }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactionHandler.d.ts","sourceRoot":"","sources":["../../../../src/components/Message/hooks/useReactionHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAA4C,MAAM,OAAO,CAAC;AAInF,OAAO,EAAE,aAAa,EAA0B,MAAM,sCAAsC,CAAC;AAG7F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIlD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,eAAO,MAAM,sBAAsB,4MACsF,CAAC;AAE1H,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"useReactionHandler.d.ts","sourceRoot":"","sources":["../../../../src/components/Message/hooks/useReactionHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAA4C,MAAM,OAAO,CAAC;AAInF,OAAO,EAAE,aAAa,EAA0B,MAAM,sCAAsC,CAAC;AAG7F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIlD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,eAAO,MAAM,sBAAsB,4MACsF,CAAC;AAE1H,eAAO,MAAM,kBAAkB,gKAgFD,MAAM,UAAU,MAAM,kBAAkB,kBAmCrE,CAAC;AAEF,eAAO,MAAM,gBAAgB,oKAIL,UAAU,cAAc,GAAG,IAAI,CAAC,sBAClC,UAAU,cAAc,GAAG,IAAI,CAAC,iCACrB,OAAO;;;;CAwFvC,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { useChatContext } from '../../../context/ChatContext';
|
|
|
7
7
|
export var reactionHandlerWarning = "Reaction handler was called, but it is missing one of its required arguments.\nMake sure the ChannelAction and ChannelState contexts are properly set and the hook is initialized with a valid message.";
|
|
8
8
|
export var useReactionHandler = function (message) {
|
|
9
9
|
var updateMessage = useChannelActionContext('useReactionHandler').updateMessage;
|
|
10
|
-
var
|
|
10
|
+
var _a = useChannelStateContext('useReactionHandler'), channel = _a.channel, channelCapabilities = _a.channelCapabilities;
|
|
11
11
|
var client = useChatContext('useReactionHandler').client;
|
|
12
12
|
var createMessagePreview = useCallback(function (add, reaction, message) {
|
|
13
13
|
var _a, _b;
|
|
@@ -31,7 +31,7 @@ export var useReactionHandler = function (message) {
|
|
|
31
31
|
? __spreadArray([reaction], ((message === null || message === void 0 ? void 0 : message.own_reactions) || []), true) : (_b = message === null || message === void 0 ? void 0 : message.own_reactions) === null || _b === void 0 ? void 0 : _b.filter(function (item) { return item.type !== reaction.type; });
|
|
32
32
|
return __assign(__assign({}, message), { latest_reactions: newReactions || message.latest_reactions, own_reactions: newOwnReactions, reaction_counts: newReactionCounts, reaction_scores: newReactionCounts });
|
|
33
33
|
}, [client.user, client.userID]);
|
|
34
|
-
var
|
|
34
|
+
var createReactionPreview = function (type) {
|
|
35
35
|
var _a;
|
|
36
36
|
return ({
|
|
37
37
|
message_id: message === null || message === void 0 ? void 0 : message.id,
|
|
@@ -43,33 +43,32 @@ export var useReactionHandler = function (message) {
|
|
|
43
43
|
};
|
|
44
44
|
var toggleReaction = throttle(function (id, type, add) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
45
|
var newReaction, tempMessage, messageResponse, _a, error_1;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
switch (_c.label) {
|
|
46
|
+
return __generator(this, function (_b) {
|
|
47
|
+
switch (_b.label) {
|
|
49
48
|
case 0:
|
|
50
|
-
if (!message ||
|
|
49
|
+
if (!message || !channelCapabilities['send-reaction'])
|
|
51
50
|
return [2 /*return*/];
|
|
52
|
-
newReaction =
|
|
51
|
+
newReaction = createReactionPreview(type);
|
|
53
52
|
tempMessage = createMessagePreview(add, newReaction, message);
|
|
54
|
-
|
|
53
|
+
_b.label = 1;
|
|
55
54
|
case 1:
|
|
56
|
-
|
|
55
|
+
_b.trys.push([1, 6, , 7]);
|
|
57
56
|
updateMessage(tempMessage);
|
|
58
57
|
if (!add) return [3 /*break*/, 3];
|
|
59
58
|
return [4 /*yield*/, channel.sendReaction(id, { type: type })];
|
|
60
59
|
case 2:
|
|
61
|
-
_a =
|
|
60
|
+
_a = _b.sent();
|
|
62
61
|
return [3 /*break*/, 5];
|
|
63
62
|
case 3: return [4 /*yield*/, channel.deleteReaction(id, type)];
|
|
64
63
|
case 4:
|
|
65
|
-
_a =
|
|
66
|
-
|
|
64
|
+
_a = _b.sent();
|
|
65
|
+
_b.label = 5;
|
|
67
66
|
case 5:
|
|
68
67
|
messageResponse = _a;
|
|
69
68
|
updateMessage(messageResponse.message);
|
|
70
69
|
return [3 /*break*/, 7];
|
|
71
70
|
case 6:
|
|
72
|
-
error_1 =
|
|
71
|
+
error_1 = _b.sent();
|
|
73
72
|
// revert to the original message if the API call fails
|
|
74
73
|
updateMessage(message);
|
|
75
74
|
return [3 /*break*/, 7];
|
|
@@ -124,12 +123,10 @@ export var useReactionHandler = function (message) {
|
|
|
124
123
|
}); };
|
|
125
124
|
};
|
|
126
125
|
export var useReactionClick = function (message, reactionSelectorRef, messageWrapperRef, closeReactionSelectorOnClick) {
|
|
127
|
-
var _a;
|
|
128
|
-
var _b =
|
|
129
|
-
var _d = useState(false), showDetailedReactions = _d[0], setShowDetailedReactions = _d[1];
|
|
126
|
+
var _a = useChannelStateContext('useReactionClick').channelCapabilities, channelCapabilities = _a === void 0 ? {} : _a;
|
|
127
|
+
var _b = useState(false), showDetailedReactions = _b[0], setShowDetailedReactions = _b[1];
|
|
130
128
|
var hasListener = useRef(false);
|
|
131
|
-
var
|
|
132
|
-
var isReactionEnabled = ((channelConfig === null || channelConfig === void 0 ? void 0 : channelConfig.reactions) !== false && channelCapabilities['send-reaction']) || isFrozen;
|
|
129
|
+
var isReactionEnabled = channelCapabilities['send-reaction'];
|
|
133
130
|
var messageDeleted = !!(message === null || message === void 0 ? void 0 : message.deleted_at);
|
|
134
131
|
var closeDetailedReactions = useCallback(function (event) {
|
|
135
132
|
var _a;
|
|
@@ -177,9 +174,8 @@ export var useReactionClick = function (message, reactionSelectorRef, messageWra
|
|
|
177
174
|
}
|
|
178
175
|
}, [messageDeleted, closeDetailedReactions, messageWrapperRef]);
|
|
179
176
|
var onReactionListClick = function (event) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
177
|
+
var _a;
|
|
178
|
+
(_a = event === null || event === void 0 ? void 0 : event.stopPropagation) === null || _a === void 0 ? void 0 : _a.call(event);
|
|
183
179
|
setShowDetailedReactions(function (prev) { return !prev; });
|
|
184
180
|
};
|
|
185
181
|
return {
|
|
@@ -13,5 +13,5 @@ export var CooldownTimer = function (_a) {
|
|
|
13
13
|
}, 1000);
|
|
14
14
|
return function () { return clearInterval(countdownInterval); };
|
|
15
15
|
});
|
|
16
|
-
return (React.createElement("div", { className: 'str-chat__message-input-cooldown', "data-testid": 'cooldown-timer' }, seconds
|
|
16
|
+
return (React.createElement("div", { className: 'str-chat__message-input-cooldown', "data-testid": 'cooldown-timer' }, seconds));
|
|
17
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCooldownTimer.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useCooldownTimer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAK5D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,oBAAY,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,0FAExB,
|
|
1
|
+
{"version":3,"file":"useCooldownTimer.d.ts","sourceRoot":"","sources":["../../../../src/components/MessageInput/hooks/useCooldownTimer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAK5D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,oBAAY,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,0FAExB,kBAyCJ,CAAC"}
|
|
@@ -16,9 +16,12 @@ export var useCooldownTimer = function () {
|
|
|
16
16
|
}, [messages, (_a = client.user) === null || _a === void 0 ? void 0 : _a.id, latestMessageDatesByChannels, channel.cid]);
|
|
17
17
|
useEffect(function () {
|
|
18
18
|
var timeSinceOwnLastMessage = ownLatestMessageDate
|
|
19
|
-
?
|
|
19
|
+
? // prevent negative values
|
|
20
|
+
Math.max(0, (new Date().getTime() - ownLatestMessageDate.getTime()) / 1000)
|
|
20
21
|
: undefined;
|
|
21
|
-
setCooldownRemaining(!skipCooldown &&
|
|
22
|
+
setCooldownRemaining(!skipCooldown &&
|
|
23
|
+
typeof timeSinceOwnLastMessage !== 'undefined' &&
|
|
24
|
+
cooldownInterval > timeSinceOwnLastMessage
|
|
22
25
|
? Math.round(cooldownInterval - timeSinceOwnLastMessage)
|
|
23
26
|
: 0);
|
|
24
27
|
}, [cooldownInterval, ownLatestMessageDate, skipCooldown]);
|
|
@@ -45,7 +45,9 @@ export declare type MessageContextValue<StreamChatGenerics extends DefaultStream
|
|
|
45
45
|
handleRetry: ChannelActionContextValue<StreamChatGenerics>['retrySendMessage'];
|
|
46
46
|
/** Function that returns whether or not the Message belongs to the current user */
|
|
47
47
|
isMyMessage: () => boolean;
|
|
48
|
-
/**
|
|
48
|
+
/** @deprecated will be removed in the next major release.
|
|
49
|
+
* Whether sending reactions is enabled for the active channel.
|
|
50
|
+
*/
|
|
49
51
|
isReactionEnabled: boolean;
|
|
50
52
|
/** The message object */
|
|
51
53
|
message: StreamMessage<StreamChatGenerics>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageContext.d.ts","sourceRoot":"","sources":["../../src/context/MessageContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EA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AC5C,6KAA6K;IAC7K,UAAU,CAAC,EAAE,CACX,IAAI,CAAC,EAAE,MAAM,EACb,eAAe,CAAC,EAAE,YAAY,CAAC,kBAAkB,CAAC,EAAE,EACpD,OAAO,CAAC,EAAE,iBAAiB,KACxB,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,gDAAgD;IAChD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gFAAgF;IAChF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,cAAc,2EAAkE,CAAC;AAE9F,eAAO,MAAM,eAAe;;kBAW3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,qGAGZ,MAAM,4CAavB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;CAqB9B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import Dayjs from 'dayjs';
|
|
3
3
|
import type { TFunction } from 'i18next';
|
|
4
|
-
import type { Moment } from 'moment';
|
|
4
|
+
import type { Moment } from 'moment-timezone';
|
|
5
5
|
import type { TranslationLanguages } from 'stream-chat';
|
|
6
6
|
import type { UnknownType } from '../types/types';
|
|
7
7
|
export declare type SupportedTranslations = 'de' | 'en' | 'es' | 'fr' | 'hi' | 'it' | 'ja' | 'ko' | 'nl' | 'pt' | 'ru' | 'tr';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationContext.d.ts","sourceRoot":"","sources":["../../src/context/TranslationContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"TranslationContext.d.ts","sourceRoot":"","sources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O,MAAM,mBAAmB;WAGF,uBAAuB;kBAEpD,CAAC;AAEF,eAAO,MAAM,qBAAqB,mBAAoB,MAAM,4BAY3D,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;CAclC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
2
|
import Dayjs from 'dayjs';
|
|
3
|
-
import type
|
|
3
|
+
import type momentTimezone from 'moment-timezone';
|
|
4
4
|
import type { TranslationLanguages } from 'stream-chat';
|
|
5
5
|
import type { TDateTimeParser } from '../context/TranslationContext';
|
|
6
6
|
import type { UnknownType } from '../types/types';
|
|
@@ -25,8 +25,9 @@ declare type CalendarLocaleConfig = {
|
|
|
25
25
|
sameDay: string;
|
|
26
26
|
sameElse: string;
|
|
27
27
|
};
|
|
28
|
+
declare type DateTimeParserModule = typeof Dayjs | typeof momentTimezone;
|
|
28
29
|
declare type Options = {
|
|
29
|
-
DateTimeParser?:
|
|
30
|
+
DateTimeParser?: DateTimeParserModule;
|
|
30
31
|
dayjsLocaleConfigForLanguage?: Partial<ILocale> & {
|
|
31
32
|
calendar?: CalendarLocaleConfig;
|
|
32
33
|
};
|
|
@@ -34,6 +35,7 @@ declare type Options = {
|
|
|
34
35
|
disableDateTimeTranslations?: boolean;
|
|
35
36
|
language?: TranslationLanguages;
|
|
36
37
|
logger?: (message?: string) => void;
|
|
38
|
+
timezone?: string;
|
|
37
39
|
translationsForLanguage?: Partial<typeof enTranslations>;
|
|
38
40
|
};
|
|
39
41
|
export declare const defaultTranslatorFunction: TFunction;
|
|
@@ -63,7 +65,7 @@ export declare class Streami18n {
|
|
|
63
65
|
*/
|
|
64
66
|
logger: (msg?: string) => void;
|
|
65
67
|
currentLanguage: TranslationLanguages;
|
|
66
|
-
DateTimeParser:
|
|
68
|
+
DateTimeParser: DateTimeParserModule;
|
|
67
69
|
isCustomDateTimeParser: boolean;
|
|
68
70
|
i18nextConfig: {
|
|
69
71
|
debug: boolean;
|
|
@@ -76,6 +78,10 @@ export declare class Streami18n {
|
|
|
76
78
|
nsSeparator: false;
|
|
77
79
|
parseMissingKeyHandler: (key: string) => string;
|
|
78
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* A valid TZ identifier string (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
|
|
83
|
+
*/
|
|
84
|
+
timezone?: string;
|
|
79
85
|
/**
|
|
80
86
|
* Constructor accepts following options:
|
|
81
87
|
* - language (String) default: 'en'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Streami18n.d.ts","sourceRoot":"","sources":["../../src/i18n/Streami18n.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Streami18n.d.ts","sourceRoot":"","sources":["../../src/i18n/Streami18n.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,KAAK,cAAc,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAEL,cAAc,EAWf,MAAM,gBAAgB,CAAC;AAKxB,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AACzB,OAAO,iBAAiB,CAAC;AAIzB,OA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2B,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI;CAG7D"}
|
package/dist/i18n/Streami18n.js
CHANGED
|
@@ -6,6 +6,8 @@ import updateLocale from 'dayjs/plugin/updateLocale';
|
|
|
6
6
|
import LocalizedFormat from 'dayjs/plugin/localizedFormat';
|
|
7
7
|
import localeData from 'dayjs/plugin/localeData';
|
|
8
8
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
9
|
+
import utc from 'dayjs/plugin/utc';
|
|
10
|
+
import timezone from 'dayjs/plugin/timezone';
|
|
9
11
|
import { deTranslations, enTranslations, esTranslations, frTranslations, hiTranslations, itTranslations, jaTranslations, koTranslations, nlTranslations, ptTranslations, ruTranslations, trTranslations, } from './translations';
|
|
10
12
|
var defaultNS = 'translation';
|
|
11
13
|
var defaultLng = 'en';
|
|
@@ -25,6 +27,8 @@ import 'dayjs/locale/tr';
|
|
|
25
27
|
// to make sure I don't mess up language at other places in app.
|
|
26
28
|
import 'dayjs/locale/en';
|
|
27
29
|
Dayjs.extend(updateLocale);
|
|
30
|
+
Dayjs.extend(utc);
|
|
31
|
+
Dayjs.extend(timezone);
|
|
28
32
|
Dayjs.updateLocale('de', {
|
|
29
33
|
calendar: {
|
|
30
34
|
lastDay: '[gestern um] LT',
|
|
@@ -193,6 +197,9 @@ var en_locale = {
|
|
|
193
197
|
var isDayJs = function (dateTimeParser) {
|
|
194
198
|
return dateTimeParser.extend !== undefined;
|
|
195
199
|
};
|
|
200
|
+
var supportsTz = function (dateTimeParser) {
|
|
201
|
+
return dateTimeParser.tz !== undefined;
|
|
202
|
+
};
|
|
196
203
|
/**
|
|
197
204
|
* Wrapper around [i18next](https://www.i18next.com/) class for Stream related translations.
|
|
198
205
|
* Instance of this class should be provided to Chat component to handle translations.
|
|
@@ -436,6 +443,7 @@ var Streami18n = /** @class */ (function () {
|
|
|
436
443
|
this.logger = finalOptions.logger;
|
|
437
444
|
this.currentLanguage = finalOptions.language;
|
|
438
445
|
this.DateTimeParser = finalOptions.DateTimeParser;
|
|
446
|
+
this.timezone = finalOptions.timezone;
|
|
439
447
|
try {
|
|
440
448
|
if (this.DateTimeParser && isDayJs(this.DateTimeParser)) {
|
|
441
449
|
this.DateTimeParser.extend(LocalizedFormat);
|
|
@@ -485,19 +493,18 @@ var Streami18n = /** @class */ (function () {
|
|
|
485
493
|
"register the locale config with Streami18n using registerTranslation(language, translation, customDayjsLocale)");
|
|
486
494
|
}
|
|
487
495
|
this.tDateTimeParser = function (timestamp) {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
*/
|
|
492
|
-
if (isDayJs(_this.DateTimeParser)) {
|
|
493
|
-
return _this.DateTimeParser(timestamp).locale(defaultLng);
|
|
494
|
-
}
|
|
495
|
-
return _this.DateTimeParser(timestamp).locale(defaultLng);
|
|
496
|
-
}
|
|
496
|
+
var language = finalOptions.disableDateTimeTranslations || !_this.localeExists(_this.currentLanguage)
|
|
497
|
+
? defaultLng
|
|
498
|
+
: _this.currentLanguage;
|
|
497
499
|
if (isDayJs(_this.DateTimeParser)) {
|
|
498
|
-
return _this.DateTimeParser
|
|
500
|
+
return supportsTz(_this.DateTimeParser)
|
|
501
|
+
? _this.DateTimeParser(timestamp).tz(_this.timezone).locale(language)
|
|
502
|
+
: _this.DateTimeParser(timestamp).locale(language);
|
|
503
|
+
}
|
|
504
|
+
if (supportsTz(_this.DateTimeParser) && _this.timezone) {
|
|
505
|
+
return _this.DateTimeParser(timestamp).tz(_this.timezone).locale(language);
|
|
499
506
|
}
|
|
500
|
-
return _this.DateTimeParser(timestamp).locale(
|
|
507
|
+
return _this.DateTimeParser(timestamp).locale(language);
|
|
501
508
|
};
|
|
502
509
|
}
|
|
503
510
|
/**
|
package/dist/index.cjs.js
CHANGED
|
@@ -14,6 +14,8 @@ var i18n = require('i18next');
|
|
|
14
14
|
var updateLocale = require('dayjs/plugin/updateLocale');
|
|
15
15
|
var localeData = require('dayjs/plugin/localeData');
|
|
16
16
|
var relativeTime = require('dayjs/plugin/relativeTime');
|
|
17
|
+
var utc = require('dayjs/plugin/utc');
|
|
18
|
+
var timezone = require('dayjs/plugin/timezone');
|
|
17
19
|
require('dayjs/locale/de');
|
|
18
20
|
require('dayjs/locale/es');
|
|
19
21
|
require('dayjs/locale/fr');
|
|
@@ -88,6 +90,8 @@ var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
|
|
|
88
90
|
var updateLocale__default = /*#__PURE__*/_interopDefaultLegacy(updateLocale);
|
|
89
91
|
var localeData__default = /*#__PURE__*/_interopDefaultLegacy(localeData);
|
|
90
92
|
var relativeTime__default = /*#__PURE__*/_interopDefaultLegacy(relativeTime);
|
|
93
|
+
var utc__default = /*#__PURE__*/_interopDefaultLegacy(utc);
|
|
94
|
+
var timezone__default = /*#__PURE__*/_interopDefaultLegacy(timezone);
|
|
91
95
|
var ImageGallery__default = /*#__PURE__*/_interopDefaultLegacy(ImageGallery);
|
|
92
96
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
93
97
|
var linkify__namespace = /*#__PURE__*/_interopNamespace(linkify);
|
|
@@ -609,6 +613,8 @@ var Cancel="İptal";var Close="Kapat";var Delete="Sil";var Delivered="İletildi"
|
|
|
609
613
|
var defaultNS = 'translation';
|
|
610
614
|
var defaultLng = 'en';
|
|
611
615
|
Dayjs__default["default"].extend(updateLocale__default["default"]);
|
|
616
|
+
Dayjs__default["default"].extend(utc__default["default"]);
|
|
617
|
+
Dayjs__default["default"].extend(timezone__default["default"]);
|
|
612
618
|
Dayjs__default["default"].updateLocale('de', {
|
|
613
619
|
calendar: {
|
|
614
620
|
lastDay: '[gestern um] LT',
|
|
@@ -777,6 +783,9 @@ var en_locale = {
|
|
|
777
783
|
var isDayJs = function (dateTimeParser) {
|
|
778
784
|
return dateTimeParser.extend !== undefined;
|
|
779
785
|
};
|
|
786
|
+
var supportsTz = function (dateTimeParser) {
|
|
787
|
+
return dateTimeParser.tz !== undefined;
|
|
788
|
+
};
|
|
780
789
|
/**
|
|
781
790
|
* Wrapper around [i18next](https://www.i18next.com/) class for Stream related translations.
|
|
782
791
|
* Instance of this class should be provided to Chat component to handle translations.
|
|
@@ -1020,6 +1029,7 @@ var Streami18n = /** @class */ (function () {
|
|
|
1020
1029
|
this.logger = finalOptions.logger;
|
|
1021
1030
|
this.currentLanguage = finalOptions.language;
|
|
1022
1031
|
this.DateTimeParser = finalOptions.DateTimeParser;
|
|
1032
|
+
this.timezone = finalOptions.timezone;
|
|
1023
1033
|
try {
|
|
1024
1034
|
if (this.DateTimeParser && isDayJs(this.DateTimeParser)) {
|
|
1025
1035
|
this.DateTimeParser.extend(LocalizedFormat__default["default"]);
|
|
@@ -1069,19 +1079,18 @@ var Streami18n = /** @class */ (function () {
|
|
|
1069
1079
|
"register the locale config with Streami18n using registerTranslation(language, translation, customDayjsLocale)");
|
|
1070
1080
|
}
|
|
1071
1081
|
this.tDateTimeParser = function (timestamp) {
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
*/
|
|
1076
|
-
if (isDayJs(_this.DateTimeParser)) {
|
|
1077
|
-
return _this.DateTimeParser(timestamp).locale(defaultLng);
|
|
1078
|
-
}
|
|
1079
|
-
return _this.DateTimeParser(timestamp).locale(defaultLng);
|
|
1080
|
-
}
|
|
1082
|
+
var language = finalOptions.disableDateTimeTranslations || !_this.localeExists(_this.currentLanguage)
|
|
1083
|
+
? defaultLng
|
|
1084
|
+
: _this.currentLanguage;
|
|
1081
1085
|
if (isDayJs(_this.DateTimeParser)) {
|
|
1082
|
-
return _this.DateTimeParser
|
|
1086
|
+
return supportsTz(_this.DateTimeParser)
|
|
1087
|
+
? _this.DateTimeParser(timestamp).tz(_this.timezone).locale(language)
|
|
1088
|
+
: _this.DateTimeParser(timestamp).locale(language);
|
|
1083
1089
|
}
|
|
1084
|
-
|
|
1090
|
+
if (supportsTz(_this.DateTimeParser) && _this.timezone) {
|
|
1091
|
+
return _this.DateTimeParser(timestamp).tz(_this.timezone).locale(language);
|
|
1092
|
+
}
|
|
1093
|
+
return _this.DateTimeParser(timestamp).locale(language);
|
|
1085
1094
|
};
|
|
1086
1095
|
}
|
|
1087
1096
|
/**
|
|
@@ -30422,7 +30431,7 @@ var CooldownTimer = function (_a) {
|
|
|
30422
30431
|
}, 1000);
|
|
30423
30432
|
return function () { return clearInterval(countdownInterval); };
|
|
30424
30433
|
});
|
|
30425
|
-
return (React__default["default"].createElement("div", { className: 'str-chat__message-input-cooldown', "data-testid": 'cooldown-timer' }, seconds
|
|
30434
|
+
return (React__default["default"].createElement("div", { className: 'str-chat__message-input-cooldown', "data-testid": 'cooldown-timer' }, seconds));
|
|
30426
30435
|
};
|
|
30427
30436
|
|
|
30428
30437
|
var useCommandTrigger = function () {
|
|
@@ -31138,9 +31147,12 @@ var useCooldownTimer = function () {
|
|
|
31138
31147
|
}, [messages, (_a = client.user) === null || _a === void 0 ? void 0 : _a.id, latestMessageDatesByChannels, channel.cid]);
|
|
31139
31148
|
React.useEffect(function () {
|
|
31140
31149
|
var timeSinceOwnLastMessage = ownLatestMessageDate
|
|
31141
|
-
?
|
|
31150
|
+
? // prevent negative values
|
|
31151
|
+
Math.max(0, (new Date().getTime() - ownLatestMessageDate.getTime()) / 1000)
|
|
31142
31152
|
: undefined;
|
|
31143
|
-
setCooldownRemaining(!skipCooldown &&
|
|
31153
|
+
setCooldownRemaining(!skipCooldown &&
|
|
31154
|
+
typeof timeSinceOwnLastMessage !== 'undefined' &&
|
|
31155
|
+
cooldownInterval > timeSinceOwnLastMessage
|
|
31144
31156
|
? Math.round(cooldownInterval - timeSinceOwnLastMessage)
|
|
31145
31157
|
: 0);
|
|
31146
31158
|
}, [cooldownInterval, ownLatestMessageDate, skipCooldown]);
|
|
@@ -32575,6 +32587,13 @@ var MessageSimpleWithContext = function (props) {
|
|
|
32575
32587
|
if (message.deleted_at || message.type === 'deleted') {
|
|
32576
32588
|
return React__default["default"].createElement(MessageDeleted$1, { message: message });
|
|
32577
32589
|
}
|
|
32590
|
+
/** FIXME: isReactionEnabled should be removed with next major version and a proper centralized permissions logic should be put in place
|
|
32591
|
+
* With the current permissions implementation it would be sth like:
|
|
32592
|
+
* const messageActions = getMessageActions();
|
|
32593
|
+
* const canReact = messageActions.includes(MESSAGE_ACTIONS.react);
|
|
32594
|
+
*/
|
|
32595
|
+
var canReact = isReactionEnabled;
|
|
32596
|
+
var canShowReactions = hasReactions;
|
|
32578
32597
|
var showMetadata = !groupedByUser || endOfGroup;
|
|
32579
32598
|
var showReplyCountButton = !threadList && !!message.reply_count;
|
|
32580
32599
|
var allowRetry = message.status === 'failed' && message.errorStatusCode !== 403;
|
|
@@ -32584,7 +32603,7 @@ var MessageSimpleWithContext = function (props) {
|
|
|
32584
32603
|
'pinned-message': message.pinned,
|
|
32585
32604
|
'str-chat__message--has-attachment': hasAttachment,
|
|
32586
32605
|
'str-chat__message--highlighted': highlighted,
|
|
32587
|
-
'str-chat__message--with-reactions str-chat__message-with-thread-link':
|
|
32606
|
+
'str-chat__message--with-reactions str-chat__message-with-thread-link': canShowReactions,
|
|
32588
32607
|
'str-chat__message-send-can-be-retried': (message === null || message === void 0 ? void 0 : message.status) === 'failed' && (message === null || message === void 0 ? void 0 : message.errorStatusCode) !== 403,
|
|
32589
32608
|
'str-chat__virtual-message__wrapper--end': endOfGroup,
|
|
32590
32609
|
'str-chat__virtual-message__wrapper--first': firstOfGroup,
|
|
@@ -32601,8 +32620,8 @@ var MessageSimpleWithContext = function (props) {
|
|
|
32601
32620
|
}), "data-testid": 'message-inner', onClick: allowRetry ? function () { return handleRetry(message); } : undefined, onKeyUp: allowRetry ? function () { return handleRetry(message); } : undefined },
|
|
32602
32621
|
React__default["default"].createElement(MessageOptions$1, null),
|
|
32603
32622
|
React__default["default"].createElement("div", { className: 'str-chat__message-reactions-host' },
|
|
32604
|
-
|
|
32605
|
-
showDetailedReactions &&
|
|
32623
|
+
canShowReactions && React__default["default"].createElement(ReactionsList$1, { reverse: true }),
|
|
32624
|
+
showDetailedReactions && canReact && React__default["default"].createElement(ReactionSelector$1, { ref: reactionSelectorRef })),
|
|
32606
32625
|
React__default["default"].createElement("div", { className: 'str-chat__message-bubble' },
|
|
32607
32626
|
((_a = message.attachments) === null || _a === void 0 ? void 0 : _a.length) && !message.quoted_message ? (React__default["default"].createElement(Attachment, { actionHandler: handleAction, attachments: message.attachments })) : null,
|
|
32608
32627
|
React__default["default"].createElement(MessageText, { message: message, renderText: renderText }),
|
|
@@ -34868,7 +34887,7 @@ var UnMemoizedChannelList = function (props) {
|
|
|
34868
34887
|
*/
|
|
34869
34888
|
var ChannelList = React__default["default"].memo(UnMemoizedChannelList);
|
|
34870
34889
|
|
|
34871
|
-
var version = '10.
|
|
34890
|
+
var version = '10.11.0';
|
|
34872
34891
|
|
|
34873
34892
|
var useChat = function (_a) {
|
|
34874
34893
|
var _b, _c;
|
|
@@ -35520,7 +35539,7 @@ notifications) {
|
|
|
35520
35539
|
var reactionHandlerWarning = "Reaction handler was called, but it is missing one of its required arguments.\nMake sure the ChannelAction and ChannelState contexts are properly set and the hook is initialized with a valid message.";
|
|
35521
35540
|
var useReactionHandler = function (message) {
|
|
35522
35541
|
var updateMessage = useChannelActionContext('useReactionHandler').updateMessage;
|
|
35523
|
-
var
|
|
35542
|
+
var _a = useChannelStateContext('useReactionHandler'), channel = _a.channel, channelCapabilities = _a.channelCapabilities;
|
|
35524
35543
|
var client = useChatContext('useReactionHandler').client;
|
|
35525
35544
|
var createMessagePreview = React.useCallback(function (add, reaction, message) {
|
|
35526
35545
|
var _a, _b;
|
|
@@ -35544,7 +35563,7 @@ var useReactionHandler = function (message) {
|
|
|
35544
35563
|
? __spreadArray([reaction], ((message === null || message === void 0 ? void 0 : message.own_reactions) || []), true) : (_b = message === null || message === void 0 ? void 0 : message.own_reactions) === null || _b === void 0 ? void 0 : _b.filter(function (item) { return item.type !== reaction.type; });
|
|
35545
35564
|
return __assign(__assign({}, message), { latest_reactions: newReactions || message.latest_reactions, own_reactions: newOwnReactions, reaction_counts: newReactionCounts, reaction_scores: newReactionCounts });
|
|
35546
35565
|
}, [client.user, client.userID]);
|
|
35547
|
-
var
|
|
35566
|
+
var createReactionPreview = function (type) {
|
|
35548
35567
|
var _a;
|
|
35549
35568
|
return ({
|
|
35550
35569
|
message_id: message === null || message === void 0 ? void 0 : message.id,
|
|
@@ -35556,33 +35575,32 @@ var useReactionHandler = function (message) {
|
|
|
35556
35575
|
};
|
|
35557
35576
|
var toggleReaction = throttle__default["default"](function (id, type, add) { return __awaiter(void 0, void 0, void 0, function () {
|
|
35558
35577
|
var newReaction, tempMessage, messageResponse, _a;
|
|
35559
|
-
|
|
35560
|
-
|
|
35561
|
-
switch (_c.label) {
|
|
35578
|
+
return __generator(this, function (_b) {
|
|
35579
|
+
switch (_b.label) {
|
|
35562
35580
|
case 0:
|
|
35563
|
-
if (!message ||
|
|
35581
|
+
if (!message || !channelCapabilities['send-reaction'])
|
|
35564
35582
|
return [2 /*return*/];
|
|
35565
|
-
newReaction =
|
|
35583
|
+
newReaction = createReactionPreview(type);
|
|
35566
35584
|
tempMessage = createMessagePreview(add, newReaction, message);
|
|
35567
|
-
|
|
35585
|
+
_b.label = 1;
|
|
35568
35586
|
case 1:
|
|
35569
|
-
|
|
35587
|
+
_b.trys.push([1, 6, , 7]);
|
|
35570
35588
|
updateMessage(tempMessage);
|
|
35571
35589
|
if (!add) return [3 /*break*/, 3];
|
|
35572
35590
|
return [4 /*yield*/, channel.sendReaction(id, { type: type })];
|
|
35573
35591
|
case 2:
|
|
35574
|
-
_a =
|
|
35592
|
+
_a = _b.sent();
|
|
35575
35593
|
return [3 /*break*/, 5];
|
|
35576
35594
|
case 3: return [4 /*yield*/, channel.deleteReaction(id, type)];
|
|
35577
35595
|
case 4:
|
|
35578
|
-
_a =
|
|
35579
|
-
|
|
35596
|
+
_a = _b.sent();
|
|
35597
|
+
_b.label = 5;
|
|
35580
35598
|
case 5:
|
|
35581
35599
|
messageResponse = _a;
|
|
35582
35600
|
updateMessage(messageResponse.message);
|
|
35583
35601
|
return [3 /*break*/, 7];
|
|
35584
35602
|
case 6:
|
|
35585
|
-
|
|
35603
|
+
_b.sent();
|
|
35586
35604
|
// revert to the original message if the API call fails
|
|
35587
35605
|
updateMessage(message);
|
|
35588
35606
|
return [3 /*break*/, 7];
|
|
@@ -35637,12 +35655,10 @@ var useReactionHandler = function (message) {
|
|
|
35637
35655
|
}); };
|
|
35638
35656
|
};
|
|
35639
35657
|
var useReactionClick = function (message, reactionSelectorRef, messageWrapperRef, closeReactionSelectorOnClick) {
|
|
35640
|
-
var _a;
|
|
35641
|
-
var _b =
|
|
35642
|
-
var _d = React.useState(false), showDetailedReactions = _d[0], setShowDetailedReactions = _d[1];
|
|
35658
|
+
var _a = useChannelStateContext('useReactionClick').channelCapabilities, channelCapabilities = _a === void 0 ? {} : _a;
|
|
35659
|
+
var _b = React.useState(false), showDetailedReactions = _b[0], setShowDetailedReactions = _b[1];
|
|
35643
35660
|
var hasListener = React.useRef(false);
|
|
35644
|
-
var
|
|
35645
|
-
var isReactionEnabled = ((channelConfig === null || channelConfig === void 0 ? void 0 : channelConfig.reactions) !== false && channelCapabilities['send-reaction']) || isFrozen;
|
|
35661
|
+
var isReactionEnabled = channelCapabilities['send-reaction'];
|
|
35646
35662
|
var messageDeleted = !!(message === null || message === void 0 ? void 0 : message.deleted_at);
|
|
35647
35663
|
var closeDetailedReactions = React.useCallback(function (event) {
|
|
35648
35664
|
var _a;
|
|
@@ -35690,9 +35706,8 @@ var useReactionClick = function (message, reactionSelectorRef, messageWrapperRef
|
|
|
35690
35706
|
}
|
|
35691
35707
|
}, [messageDeleted, closeDetailedReactions, messageWrapperRef]);
|
|
35692
35708
|
var onReactionListClick = function (event) {
|
|
35693
|
-
|
|
35694
|
-
|
|
35695
|
-
}
|
|
35709
|
+
var _a;
|
|
35710
|
+
(_a = event === null || event === void 0 ? void 0 : event.stopPropagation) === null || _a === void 0 ? void 0 : _a.call(event);
|
|
35696
35711
|
setShowDetailedReactions(function (prev) { return !prev; });
|
|
35697
35712
|
};
|
|
35698
35713
|
return {
|