stream-chat-react 12.15.1 → 12.15.3
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/components/Chat/hooks/useChat.js +1 -1
- package/dist/components/Dialog/DialogManager.js +2 -1
- package/dist/components/MessageInput/AttachmentSelector.js +3 -3
- package/dist/components/MessageInput/MessageInput.js +4 -2
- package/dist/components/MessageList/MessageList.js +4 -2
- package/dist/components/MessageList/VirtualizedMessageList.js +4 -2
- package/dist/components/Poll/PollCreationDialog/PollCreationDialog.js +3 -2
- package/dist/components/UtilityComponents/useStableId.d.ts +5 -0
- package/dist/components/UtilityComponents/useStableId.js +11 -0
- package/dist/css/v2/index.css +1 -1
- package/dist/css/v2/index.layout.css +1 -1
- package/dist/experimental/index.browser.cjs.map +1 -1
- package/dist/experimental/index.node.cjs.map +1 -1
- package/dist/index.browser.cjs +687 -676
- package/dist/index.browser.cjs.map +4 -4
- package/dist/index.node.cjs +576 -565
- package/dist/index.node.cjs.map +4 -4
- package/dist/scss/v2/Autocomplete/Autocomplete-layout.scss +14 -0
- package/dist/scss/v2/Autocomplete/Autocomplete-theme.scss +11 -0
- package/dist/scss/v2/LinkPreview/LinkPreview-layout.scss +18 -0
- package/dist/scss/v2/LinkPreview/LinkPreview-theme.scss +15 -0
- package/dist/scss/v2/MessageInput/MessageInput-layout.scss +5 -0
- package/package.json +2 -2
package/dist/index.node.cjs
CHANGED
|
@@ -20940,13 +20940,14 @@ var withComponentContext = (Component2) => {
|
|
|
20940
20940
|
var import_react10 = __toESM(require("react"));
|
|
20941
20941
|
|
|
20942
20942
|
// src/components/Dialog/DialogManager.ts
|
|
20943
|
+
var import_nanoid = require("nanoid");
|
|
20943
20944
|
var import_stream_chat = require("stream-chat");
|
|
20944
20945
|
var DialogManager = class {
|
|
20945
20946
|
constructor({ id } = {}) {
|
|
20946
20947
|
this.state = new import_stream_chat.StateStore({
|
|
20947
20948
|
dialogsById: {}
|
|
20948
20949
|
});
|
|
20949
|
-
this.id = id ?? (
|
|
20950
|
+
this.id = id ?? (0, import_nanoid.nanoid)();
|
|
20950
20951
|
}
|
|
20951
20952
|
get openDialogCount() {
|
|
20952
20953
|
return Object.values(this.state.getLatestValue().dialogsById).reduce(
|
|
@@ -23205,7 +23206,7 @@ var ImageDropzone = ({
|
|
|
23205
23206
|
|
|
23206
23207
|
// src/components/ReactFileUtilities/UploadButton.tsx
|
|
23207
23208
|
var import_clsx5 = __toESM(require("clsx"));
|
|
23208
|
-
var
|
|
23209
|
+
var import_nanoid2 = require("nanoid");
|
|
23209
23210
|
var import_react34 = __toESM(require("react"));
|
|
23210
23211
|
|
|
23211
23212
|
// src/components/ReactFileUtilities/utils.ts
|
|
@@ -23321,7 +23322,7 @@ var UploadFileInput = (0, import_react34.forwardRef)(function UploadFileInput2({
|
|
|
23321
23322
|
const { t: t2 } = useTranslationContext("UploadFileInput");
|
|
23322
23323
|
const { acceptedFiles = [], multipleUploads } = useChannelStateContext("UploadFileInput");
|
|
23323
23324
|
const { isUploadEnabled, maxFilesLeft, uploadNewFiles } = useMessageInputContext("UploadFileInput");
|
|
23324
|
-
const id = (0, import_react34.useMemo)(() => (0,
|
|
23325
|
+
const id = (0, import_react34.useMemo)(() => (0, import_nanoid2.nanoid)(), []);
|
|
23325
23326
|
const onFileChange = (0, import_react34.useCallback)(
|
|
23326
23327
|
(files) => {
|
|
23327
23328
|
uploadNewFiles(files);
|
|
@@ -40278,11 +40279,11 @@ ReactTextareaAutocomplete.propTypes = {
|
|
|
40278
40279
|
};
|
|
40279
40280
|
|
|
40280
40281
|
// src/components/Channel/Channel.tsx
|
|
40281
|
-
var
|
|
40282
|
+
var import_react259 = __toESM(require("react"));
|
|
40282
40283
|
var import_lodash22 = __toESM(require("lodash.debounce"));
|
|
40283
40284
|
var import_lodash23 = __toESM(require("lodash.defaultsdeep"));
|
|
40284
40285
|
var import_lodash24 = __toESM(require("lodash.throttle"));
|
|
40285
|
-
var
|
|
40286
|
+
var import_nanoid12 = require("nanoid");
|
|
40286
40287
|
var import_clsx65 = __toESM(require("clsx"));
|
|
40287
40288
|
|
|
40288
40289
|
// src/components/Channel/channelState.ts
|
|
@@ -43956,11 +43957,11 @@ var useCreateMessageInputContext = (value) => {
|
|
|
43956
43957
|
|
|
43957
43958
|
// src/components/MessageInput/hooks/useMessageInputState.ts
|
|
43958
43959
|
var import_react77 = require("react");
|
|
43959
|
-
var
|
|
43960
|
+
var import_nanoid5 = require("nanoid");
|
|
43960
43961
|
|
|
43961
43962
|
// src/components/MessageInput/hooks/useAttachments.ts
|
|
43962
43963
|
var import_react71 = require("react");
|
|
43963
|
-
var
|
|
43964
|
+
var import_nanoid3 = require("nanoid");
|
|
43964
43965
|
var apiMaxNumberOfFiles = 10;
|
|
43965
43966
|
var isImageFile = (file) => file.type.startsWith("image/") && !file.type.endsWith(".photoshop");
|
|
43966
43967
|
var getAttachmentTypeFromMime = (mimeType) => {
|
|
@@ -43977,7 +43978,7 @@ var ensureIsLocalAttachment = (attachment) => {
|
|
|
43977
43978
|
return {
|
|
43978
43979
|
localMetadata: {
|
|
43979
43980
|
...localMetadata ?? {},
|
|
43980
|
-
id: localMetadata?.id || (0,
|
|
43981
|
+
id: localMetadata?.id || (0, import_nanoid3.nanoid)()
|
|
43981
43982
|
},
|
|
43982
43983
|
...rest
|
|
43983
43984
|
};
|
|
@@ -44025,7 +44026,7 @@ var useAttachments = (props, state, dispatch, textareaRef) => {
|
|
|
44025
44026
|
uploadType: isImage ? "image" : "file"
|
|
44026
44027
|
});
|
|
44027
44028
|
if (!canUpload) return att;
|
|
44028
|
-
localMetadata.id = localMetadata?.id ?? (0,
|
|
44029
|
+
localMetadata.id = localMetadata?.id ?? (0, import_nanoid3.nanoid)();
|
|
44029
44030
|
const finalAttachment = {
|
|
44030
44031
|
type: getAttachmentTypeFromMime(file.type)
|
|
44031
44032
|
};
|
|
@@ -44137,7 +44138,7 @@ var useAttachments = (props, state, dispatch, textareaRef) => {
|
|
|
44137
44138
|
fileName: generateFileName(fileLike.type),
|
|
44138
44139
|
mimeType: fileLike.type
|
|
44139
44140
|
}) : fileLike,
|
|
44140
|
-
id: (0,
|
|
44141
|
+
id: (0, import_nanoid3.nanoid)()
|
|
44141
44142
|
}
|
|
44142
44143
|
});
|
|
44143
44144
|
});
|
|
@@ -44719,7 +44720,7 @@ var BrowserPermission = class {
|
|
|
44719
44720
|
|
|
44720
44721
|
// src/components/MediaRecorder/classes/MediaRecorderController.ts
|
|
44721
44722
|
var import_fix_webm_duration = __toESM(require("fix-webm-duration"));
|
|
44722
|
-
var
|
|
44723
|
+
var import_nanoid4 = require("nanoid");
|
|
44723
44724
|
|
|
44724
44725
|
// src/utils/mergeDeep.ts
|
|
44725
44726
|
var import_lodash6 = __toESM(require("lodash.mergewith"));
|
|
@@ -44999,7 +45000,7 @@ var MediaRecorderController = class {
|
|
|
44999
45000
|
file_size: blob.size,
|
|
45000
45001
|
localMetadata: {
|
|
45001
45002
|
file,
|
|
45002
|
-
id: (0,
|
|
45003
|
+
id: (0, import_nanoid4.nanoid)()
|
|
45003
45004
|
},
|
|
45004
45005
|
mime_type: blob.type,
|
|
45005
45006
|
title: file.name,
|
|
@@ -45266,7 +45267,7 @@ var initState = (message) => {
|
|
|
45266
45267
|
const attachments = message.attachments?.filter(({ og_scrape_url }) => !og_scrape_url).map(
|
|
45267
45268
|
(att) => ({
|
|
45268
45269
|
...att,
|
|
45269
|
-
localMetadata: { id: (0,
|
|
45270
|
+
localMetadata: { id: (0, import_nanoid5.nanoid)() }
|
|
45270
45271
|
})
|
|
45271
45272
|
) || [];
|
|
45272
45273
|
const mentioned_users = message.mentioned_users || [];
|
|
@@ -45547,10 +45548,10 @@ var UnMemoizedConnectionStatus = () => {
|
|
|
45547
45548
|
var ConnectionStatus = import_react80.default.memo(UnMemoizedConnectionStatus);
|
|
45548
45549
|
|
|
45549
45550
|
// src/components/MessageList/GiphyPreviewMessage.tsx
|
|
45550
|
-
var
|
|
45551
|
+
var import_react228 = __toESM(require("react"));
|
|
45551
45552
|
|
|
45552
45553
|
// src/components/Message/Message.tsx
|
|
45553
|
-
var
|
|
45554
|
+
var import_react227 = __toESM(require("react"));
|
|
45554
45555
|
|
|
45555
45556
|
// src/components/Message/hooks/useActionHandler.ts
|
|
45556
45557
|
var handleActionWarning = `Action handler was called, but it is missing one of its required arguments.
|
|
@@ -49125,7 +49126,7 @@ var useMessageTextStreaming = ({
|
|
|
49125
49126
|
};
|
|
49126
49127
|
|
|
49127
49128
|
// src/components/Message/MessageSimple.tsx
|
|
49128
|
-
var
|
|
49129
|
+
var import_react226 = __toESM(require("react"));
|
|
49129
49130
|
var import_clsx60 = __toESM(require("clsx"));
|
|
49130
49131
|
|
|
49131
49132
|
// src/components/Message/icons.tsx
|
|
@@ -51260,12 +51261,12 @@ var Poll = ({
|
|
|
51260
51261
|
|
|
51261
51262
|
// src/components/Poll/PollCreationDialog/PollCreationDialog.tsx
|
|
51262
51263
|
var import_clsx48 = __toESM(require("clsx"));
|
|
51263
|
-
var
|
|
51264
|
+
var import_nanoid7 = require("nanoid");
|
|
51264
51265
|
var import_react179 = __toESM(require("react"));
|
|
51265
51266
|
|
|
51266
51267
|
// src/components/Poll/PollCreationDialog/OptionFieldSet.tsx
|
|
51267
51268
|
var import_clsx46 = __toESM(require("clsx"));
|
|
51268
|
-
var
|
|
51269
|
+
var import_nanoid6 = require("nanoid");
|
|
51269
51270
|
var import_react176 = __toESM(require("react"));
|
|
51270
51271
|
|
|
51271
51272
|
// src/components/DragAndDrop/DragAndDropContainer.tsx
|
|
@@ -51448,7 +51449,7 @@ var OptionFieldSet = ({
|
|
|
51448
51449
|
const shouldAddEmptyOption = prev.options.length < MAX_POLL_OPTIONS && (!prev.options || prev.options.slice(i + 1).length === 0 && !!e2.target.value);
|
|
51449
51450
|
const shouldRemoveOption = prev.options && prev.options.slice(i + 1).length > 0 && !e2.target.value;
|
|
51450
51451
|
const optionListHead = prev.options ? prev.options.slice(0, i) : [];
|
|
51451
|
-
const optionListTail = shouldAddEmptyOption ? [{ id: (0,
|
|
51452
|
+
const optionListTail = shouldAddEmptyOption ? [{ id: (0, import_nanoid6.nanoid)(), text: "" }] : (prev.options || []).slice(i + 1);
|
|
51452
51453
|
if (errors[option.id] && !e2.target.value || VALIDATION_ERRORS[errors[option.id]] && !findOptionDuplicate({ id: e2.target.id, text: e2.target.value })) {
|
|
51453
51454
|
setErrors((prev2) => {
|
|
51454
51455
|
delete prev2[option.id];
|
|
@@ -51577,10 +51578,10 @@ var PollCreationDialog = ({ close }) => {
|
|
|
51577
51578
|
allow_user_suggested_options: false,
|
|
51578
51579
|
description: "",
|
|
51579
51580
|
enforce_unique_vote: true,
|
|
51580
|
-
id: (0,
|
|
51581
|
+
id: (0, import_nanoid7.nanoid)(),
|
|
51581
51582
|
max_votes_allowed: "",
|
|
51582
51583
|
name: "",
|
|
51583
|
-
options: [{ id: (0,
|
|
51584
|
+
options: [{ id: (0, import_nanoid7.nanoid)(), text: "" }],
|
|
51584
51585
|
user_id: client.user?.id,
|
|
51585
51586
|
voting_visibility: "public"
|
|
51586
51587
|
})
|
|
@@ -51680,7 +51681,7 @@ var PollCreationDialog = ({ close }) => {
|
|
|
51680
51681
|
{
|
|
51681
51682
|
id: "max_votes_allowed",
|
|
51682
51683
|
onChange: (e2) => {
|
|
51683
|
-
const isValidValue = !e2.target.value || e2.target.value.match(VALID_MAX_VOTES_VALUE_REGEX);
|
|
51684
|
+
const isValidValue = e2.target.validity.valid && (!e2.target.value || e2.target.value.match(VALID_MAX_VOTES_VALUE_REGEX));
|
|
51684
51685
|
if (!isValidValue) {
|
|
51685
51686
|
setMultipleAnswerCountError(
|
|
51686
51687
|
t2("Type a number from 2 to 10")
|
|
@@ -51904,14 +51905,13 @@ var CUSTOM_MESSAGE_TYPE = {
|
|
|
51904
51905
|
};
|
|
51905
51906
|
|
|
51906
51907
|
// src/components/MessageInput/AttachmentSelector.tsx
|
|
51907
|
-
var
|
|
51908
|
-
var import_react187 = __toESM(require("react"));
|
|
51908
|
+
var import_react188 = __toESM(require("react"));
|
|
51909
51909
|
|
|
51910
51910
|
// src/components/MessageInput/icons.tsx
|
|
51911
51911
|
var import_react184 = __toESM(require("react"));
|
|
51912
|
-
var
|
|
51912
|
+
var import_nanoid8 = require("nanoid");
|
|
51913
51913
|
var LoadingIndicatorIcon = ({ size = 20 }) => {
|
|
51914
|
-
const id = (0, import_react184.useMemo)(() => (0,
|
|
51914
|
+
const id = (0, import_react184.useMemo)(() => (0, import_nanoid8.nanoid)(), []);
|
|
51915
51915
|
return /* @__PURE__ */ import_react184.default.createElement("div", { className: "str-chat__loading-indicator" }, /* @__PURE__ */ import_react184.default.createElement(
|
|
51916
51916
|
"svg",
|
|
51917
51917
|
{
|
|
@@ -52099,16 +52099,24 @@ var AttachmentSelectorContextProvider = ({
|
|
|
52099
52099
|
}) => /* @__PURE__ */ import_react186.default.createElement(AttachmentSelectorContext.Provider, { value }, children);
|
|
52100
52100
|
var useAttachmentSelectorContext = () => (0, import_react186.useContext)(AttachmentSelectorContext);
|
|
52101
52101
|
|
|
52102
|
+
// src/components/UtilityComponents/useStableId.ts
|
|
52103
|
+
var import_nanoid9 = require("nanoid");
|
|
52104
|
+
var import_react187 = require("react");
|
|
52105
|
+
var useStableId = (key) => {
|
|
52106
|
+
const id = (0, import_react187.useMemo)(() => (0, import_nanoid9.nanoid)(), [key]);
|
|
52107
|
+
return id;
|
|
52108
|
+
};
|
|
52109
|
+
|
|
52102
52110
|
// src/components/MessageInput/AttachmentSelector.tsx
|
|
52103
52111
|
var SimpleAttachmentSelector = () => {
|
|
52104
52112
|
const {
|
|
52105
52113
|
AttachmentSelectorInitiationButtonContents,
|
|
52106
52114
|
FileUploadIcon = UploadIcon
|
|
52107
52115
|
} = useComponentContext();
|
|
52108
|
-
const inputRef = (0,
|
|
52109
|
-
const [labelElement, setLabelElement] = (0,
|
|
52110
|
-
const id = (
|
|
52111
|
-
(0,
|
|
52116
|
+
const inputRef = (0, import_react188.useRef)(null);
|
|
52117
|
+
const [labelElement, setLabelElement] = (0, import_react188.useState)(null);
|
|
52118
|
+
const id = useStableId();
|
|
52119
|
+
(0, import_react188.useEffect)(() => {
|
|
52112
52120
|
if (!labelElement) return;
|
|
52113
52121
|
const handleKeyUp = (event) => {
|
|
52114
52122
|
if (![" ", "Enter"].includes(event.key) || !inputRef.current) return;
|
|
@@ -52120,7 +52128,7 @@ var SimpleAttachmentSelector = () => {
|
|
|
52120
52128
|
labelElement.removeEventListener("keyup", handleKeyUp);
|
|
52121
52129
|
};
|
|
52122
52130
|
}, [labelElement]);
|
|
52123
|
-
return /* @__PURE__ */
|
|
52131
|
+
return /* @__PURE__ */ import_react188.default.createElement("div", { className: "str-chat__file-input-container", "data-testid": "file-upload-button" }, /* @__PURE__ */ import_react188.default.createElement(UploadFileInput, { id, ref: inputRef }), /* @__PURE__ */ import_react188.default.createElement(
|
|
52124
52132
|
"label",
|
|
52125
52133
|
{
|
|
52126
52134
|
className: "str-chat__file-input-label",
|
|
@@ -52128,24 +52136,24 @@ var SimpleAttachmentSelector = () => {
|
|
|
52128
52136
|
ref: setLabelElement,
|
|
52129
52137
|
tabIndex: 0
|
|
52130
52138
|
},
|
|
52131
|
-
AttachmentSelectorInitiationButtonContents ? /* @__PURE__ */
|
|
52139
|
+
AttachmentSelectorInitiationButtonContents ? /* @__PURE__ */ import_react188.default.createElement(AttachmentSelectorInitiationButtonContents, null) : /* @__PURE__ */ import_react188.default.createElement(FileUploadIcon, null)
|
|
52132
52140
|
));
|
|
52133
52141
|
};
|
|
52134
52142
|
var AttachmentSelectorMenuInitButtonIcon = () => {
|
|
52135
52143
|
const { AttachmentSelectorInitiationButtonContents, FileUploadIcon } = useComponentContext("SimpleAttachmentSelector");
|
|
52136
52144
|
if (AttachmentSelectorInitiationButtonContents) {
|
|
52137
|
-
return /* @__PURE__ */
|
|
52145
|
+
return /* @__PURE__ */ import_react188.default.createElement(AttachmentSelectorInitiationButtonContents, null);
|
|
52138
52146
|
}
|
|
52139
52147
|
if (FileUploadIcon) {
|
|
52140
|
-
return /* @__PURE__ */
|
|
52148
|
+
return /* @__PURE__ */ import_react188.default.createElement(FileUploadIcon, null);
|
|
52141
52149
|
}
|
|
52142
|
-
return /* @__PURE__ */
|
|
52150
|
+
return /* @__PURE__ */ import_react188.default.createElement("div", { className: "str-chat__attachment-selector__menu-button__icon" });
|
|
52143
52151
|
};
|
|
52144
52152
|
var DefaultAttachmentSelectorComponents = {
|
|
52145
52153
|
File({ closeMenu }) {
|
|
52146
52154
|
const { t: t2 } = useTranslationContext();
|
|
52147
52155
|
const { fileInput } = useAttachmentSelectorContext();
|
|
52148
|
-
return /* @__PURE__ */
|
|
52156
|
+
return /* @__PURE__ */ import_react188.default.createElement(
|
|
52149
52157
|
DialogMenuButton,
|
|
52150
52158
|
{
|
|
52151
52159
|
className: "str-chat__attachment-selector-actions-menu__button str-chat__attachment-selector-actions-menu__upload-file-button",
|
|
@@ -52159,7 +52167,7 @@ var DefaultAttachmentSelectorComponents = {
|
|
|
52159
52167
|
},
|
|
52160
52168
|
Poll({ closeMenu, openModalForAction }) {
|
|
52161
52169
|
const { t: t2 } = useTranslationContext();
|
|
52162
|
-
return /* @__PURE__ */
|
|
52170
|
+
return /* @__PURE__ */ import_react188.default.createElement(
|
|
52163
52171
|
DialogMenuButton,
|
|
52164
52172
|
{
|
|
52165
52173
|
className: "str-chat__attachment-selector-actions-menu__button str-chat__attachment-selector-actions-menu__create-poll-button",
|
|
@@ -52209,8 +52217,8 @@ var AttachmentSelector = ({
|
|
|
52209
52217
|
const menuDialogId = `attachment-actions-menu${isThreadInput ? "-thread" : ""}`;
|
|
52210
52218
|
const menuDialog = useDialog({ id: menuDialogId });
|
|
52211
52219
|
const menuDialogIsOpen = useDialogIsOpen(menuDialogId);
|
|
52212
|
-
const [modalContentAction, setModalContentActionAction] = (0,
|
|
52213
|
-
const openModal = (0,
|
|
52220
|
+
const [modalContentAction, setModalContentActionAction] = (0, import_react188.useState)();
|
|
52221
|
+
const openModal = (0, import_react188.useCallback)(
|
|
52214
52222
|
(actionType) => {
|
|
52215
52223
|
const action = actions.find((a2) => a2.type === actionType);
|
|
52216
52224
|
if (!action?.ModalContent) return;
|
|
@@ -52218,19 +52226,19 @@ var AttachmentSelector = ({
|
|
|
52218
52226
|
},
|
|
52219
52227
|
[actions]
|
|
52220
52228
|
);
|
|
52221
|
-
const closeModal = (0,
|
|
52222
|
-
const [fileInput, setFileInput] = (0,
|
|
52223
|
-
const menuButtonRef = (0,
|
|
52224
|
-
const getDefaultPortalDestination = (0,
|
|
52229
|
+
const closeModal = (0, import_react188.useCallback)(() => setModalContentActionAction(void 0), []);
|
|
52230
|
+
const [fileInput, setFileInput] = (0, import_react188.useState)(null);
|
|
52231
|
+
const menuButtonRef = (0, import_react188.useRef)(null);
|
|
52232
|
+
const getDefaultPortalDestination = (0, import_react188.useCallback)(
|
|
52225
52233
|
() => document.getElementById(CHANNEL_CONTAINER_ID),
|
|
52226
52234
|
[]
|
|
52227
52235
|
);
|
|
52228
52236
|
if (actions.length === 0) return null;
|
|
52229
52237
|
if (actions.length === 1 && actions[0].type === "uploadFile")
|
|
52230
|
-
return /* @__PURE__ */
|
|
52238
|
+
return /* @__PURE__ */ import_react188.default.createElement(SimpleAttachmentSelector, null);
|
|
52231
52239
|
const ModalContent = modalContentAction?.ModalContent;
|
|
52232
52240
|
const modalIsOpen = !!ModalContent;
|
|
52233
|
-
return /* @__PURE__ */
|
|
52241
|
+
return /* @__PURE__ */ import_react188.default.createElement(AttachmentSelectorContextProvider, { value: { fileInput } }, /* @__PURE__ */ import_react188.default.createElement("div", { className: "str-chat__attachment-selector" }, channelCapabilities["upload-file"] && /* @__PURE__ */ import_react188.default.createElement(UploadFileInput, { ref: setFileInput }), /* @__PURE__ */ import_react188.default.createElement(
|
|
52234
52242
|
"button",
|
|
52235
52243
|
{
|
|
52236
52244
|
"aria-expanded": menuDialogIsOpen,
|
|
@@ -52241,8 +52249,8 @@ var AttachmentSelector = ({
|
|
|
52241
52249
|
onClick: () => menuDialog?.toggle(),
|
|
52242
52250
|
ref: menuButtonRef
|
|
52243
52251
|
},
|
|
52244
|
-
/* @__PURE__ */
|
|
52245
|
-
), /* @__PURE__ */
|
|
52252
|
+
/* @__PURE__ */ import_react188.default.createElement(AttachmentSelectorMenuInitButtonIcon, null)
|
|
52253
|
+
), /* @__PURE__ */ import_react188.default.createElement(
|
|
52246
52254
|
DialogAnchor,
|
|
52247
52255
|
{
|
|
52248
52256
|
id: menuDialogId,
|
|
@@ -52250,13 +52258,13 @@ var AttachmentSelector = ({
|
|
|
52250
52258
|
referenceElement: menuButtonRef.current,
|
|
52251
52259
|
trapFocus: true
|
|
52252
52260
|
},
|
|
52253
|
-
/* @__PURE__ */
|
|
52261
|
+
/* @__PURE__ */ import_react188.default.createElement(
|
|
52254
52262
|
"div",
|
|
52255
52263
|
{
|
|
52256
52264
|
className: "str-chat__attachment-selector-actions-menu str-chat__dialog-menu",
|
|
52257
52265
|
"data-testid": "attachment-selector-actions-menu"
|
|
52258
52266
|
},
|
|
52259
|
-
actions.map(({ ActionButton, type }) => /* @__PURE__ */
|
|
52267
|
+
actions.map(({ ActionButton, type }) => /* @__PURE__ */ import_react188.default.createElement(
|
|
52260
52268
|
ActionButton,
|
|
52261
52269
|
{
|
|
52262
52270
|
closeMenu: menuDialog.close,
|
|
@@ -52265,29 +52273,29 @@ var AttachmentSelector = ({
|
|
|
52265
52273
|
}
|
|
52266
52274
|
))
|
|
52267
52275
|
)
|
|
52268
|
-
), /* @__PURE__ */
|
|
52276
|
+
), /* @__PURE__ */ import_react188.default.createElement(
|
|
52269
52277
|
Portal,
|
|
52270
52278
|
{
|
|
52271
52279
|
getPortalDestination: getModalPortalDestination ?? getDefaultPortalDestination,
|
|
52272
52280
|
isOpen: modalIsOpen
|
|
52273
52281
|
},
|
|
52274
|
-
/* @__PURE__ */
|
|
52282
|
+
/* @__PURE__ */ import_react188.default.createElement(
|
|
52275
52283
|
Modal,
|
|
52276
52284
|
{
|
|
52277
52285
|
className: "str-chat__create-poll-modal",
|
|
52278
52286
|
onClose: closeModal,
|
|
52279
52287
|
open: modalIsOpen
|
|
52280
52288
|
},
|
|
52281
|
-
ModalContent && /* @__PURE__ */
|
|
52289
|
+
ModalContent && /* @__PURE__ */ import_react188.default.createElement(ModalContent, { close: closeModal })
|
|
52282
52290
|
)
|
|
52283
52291
|
)));
|
|
52284
52292
|
};
|
|
52285
52293
|
|
|
52286
52294
|
// src/components/MessageInput/AttachmentPreviewList/AttachmentPreviewList.tsx
|
|
52287
|
-
var
|
|
52295
|
+
var import_react200 = __toESM(require("react"));
|
|
52288
52296
|
|
|
52289
52297
|
// src/components/MessageInput/AttachmentPreviewList/UnsupportedAttachmentPreview.tsx
|
|
52290
|
-
var
|
|
52298
|
+
var import_react189 = __toESM(require("react"));
|
|
52291
52299
|
var UnsupportedAttachmentPreview = ({
|
|
52292
52300
|
attachment,
|
|
52293
52301
|
handleRetry,
|
|
@@ -52295,14 +52303,14 @@ var UnsupportedAttachmentPreview = ({
|
|
|
52295
52303
|
}) => {
|
|
52296
52304
|
const { t: t2 } = useTranslationContext("UnsupportedAttachmentPreview");
|
|
52297
52305
|
const title = attachment.title ?? t2("Unsupported attachment");
|
|
52298
|
-
return /* @__PURE__ */
|
|
52306
|
+
return /* @__PURE__ */ import_react189.default.createElement(
|
|
52299
52307
|
"div",
|
|
52300
52308
|
{
|
|
52301
52309
|
className: "str-chat__attachment-preview-unsupported",
|
|
52302
52310
|
"data-testid": "attachment-preview-unknown"
|
|
52303
52311
|
},
|
|
52304
|
-
/* @__PURE__ */
|
|
52305
|
-
/* @__PURE__ */
|
|
52312
|
+
/* @__PURE__ */ import_react189.default.createElement("div", { className: "str-chat__attachment-preview-file-icon" }, /* @__PURE__ */ import_react189.default.createElement(FileIcon, { filename: title, mimeType: attachment.mime_type })),
|
|
52313
|
+
/* @__PURE__ */ import_react189.default.createElement(
|
|
52306
52314
|
"button",
|
|
52307
52315
|
{
|
|
52308
52316
|
className: "str-chat__attachment-preview-delete",
|
|
@@ -52310,18 +52318,18 @@ var UnsupportedAttachmentPreview = ({
|
|
|
52310
52318
|
disabled: attachment.localMetadata?.uploadState === "uploading",
|
|
52311
52319
|
onClick: () => attachment.localMetadata?.id && removeAttachments([attachment.localMetadata?.id])
|
|
52312
52320
|
},
|
|
52313
|
-
/* @__PURE__ */
|
|
52321
|
+
/* @__PURE__ */ import_react189.default.createElement(CloseIcon, null)
|
|
52314
52322
|
),
|
|
52315
|
-
attachment.localMetadata?.uploadState === "failed" && !!handleRetry && /* @__PURE__ */
|
|
52323
|
+
attachment.localMetadata?.uploadState === "failed" && !!handleRetry && /* @__PURE__ */ import_react189.default.createElement(
|
|
52316
52324
|
"button",
|
|
52317
52325
|
{
|
|
52318
52326
|
className: "str-chat__attachment-preview-error str-chat__attachment-preview-error-file",
|
|
52319
52327
|
"data-testid": "file-preview-item-retry-button",
|
|
52320
52328
|
onClick: () => handleRetry(attachment)
|
|
52321
52329
|
},
|
|
52322
|
-
/* @__PURE__ */
|
|
52330
|
+
/* @__PURE__ */ import_react189.default.createElement(RetryIcon, null)
|
|
52323
52331
|
),
|
|
52324
|
-
/* @__PURE__ */
|
|
52332
|
+
/* @__PURE__ */ import_react189.default.createElement("div", { className: "str-chat__attachment-preview-metadata" }, /* @__PURE__ */ import_react189.default.createElement("div", { className: "str-chat__attachment-preview-title", title }, title), attachment.localMetadata?.uploadState === "finished" && !!attachment.asset_url && /* @__PURE__ */ import_react189.default.createElement(
|
|
52325
52333
|
"a",
|
|
52326
52334
|
{
|
|
52327
52335
|
className: "str-chat__attachment-preview-file-download",
|
|
@@ -52330,16 +52338,16 @@ var UnsupportedAttachmentPreview = ({
|
|
|
52330
52338
|
rel: "noreferrer",
|
|
52331
52339
|
target: "_blank"
|
|
52332
52340
|
},
|
|
52333
|
-
/* @__PURE__ */
|
|
52334
|
-
), attachment.localMetadata?.uploadState === "uploading" && /* @__PURE__ */
|
|
52341
|
+
/* @__PURE__ */ import_react189.default.createElement(DownloadIcon2, null)
|
|
52342
|
+
), attachment.localMetadata?.uploadState === "uploading" && /* @__PURE__ */ import_react189.default.createElement(LoadingIndicatorIcon, { size: 17 }))
|
|
52335
52343
|
);
|
|
52336
52344
|
};
|
|
52337
52345
|
|
|
52338
52346
|
// src/components/MessageInput/AttachmentPreviewList/VoiceRecordingPreview.tsx
|
|
52339
|
-
var
|
|
52347
|
+
var import_react197 = __toESM(require("react"));
|
|
52340
52348
|
|
|
52341
52349
|
// src/components/MediaRecorder/RecordingPermissionDeniedNotification.tsx
|
|
52342
|
-
var
|
|
52350
|
+
var import_react190 = __toESM(require("react"));
|
|
52343
52351
|
var RecordingPermissionDeniedNotification = ({
|
|
52344
52352
|
onClose,
|
|
52345
52353
|
permissionName
|
|
@@ -52355,7 +52363,7 @@ var RecordingPermissionDeniedNotification = ({
|
|
|
52355
52363
|
microphone: t2("Allow access to microphone")
|
|
52356
52364
|
}
|
|
52357
52365
|
};
|
|
52358
|
-
return /* @__PURE__ */
|
|
52366
|
+
return /* @__PURE__ */ import_react190.default.createElement("div", { className: "str-chat__recording-permission-denied-notification" }, /* @__PURE__ */ import_react190.default.createElement("div", { className: "str-chat__recording-permission-denied-notification__heading" }, permissionTranslations.heading[permissionName]), /* @__PURE__ */ import_react190.default.createElement("p", { className: "str-chat__recording-permission-denied-notification__message" }, permissionTranslations.body[permissionName]), /* @__PURE__ */ import_react190.default.createElement("div", { className: "str-chat__recording-permission-denied-notification__dismiss-button-container" }, /* @__PURE__ */ import_react190.default.createElement(
|
|
52359
52367
|
"button",
|
|
52360
52368
|
{
|
|
52361
52369
|
className: "str-chat__recording-permission-denied-notification__dismiss-button",
|
|
@@ -52366,15 +52374,15 @@ var RecordingPermissionDeniedNotification = ({
|
|
|
52366
52374
|
};
|
|
52367
52375
|
|
|
52368
52376
|
// src/components/MediaRecorder/AudioRecorder/AudioRecorder.tsx
|
|
52369
|
-
var
|
|
52377
|
+
var import_react195 = __toESM(require("react"));
|
|
52370
52378
|
|
|
52371
52379
|
// src/components/MediaRecorder/AudioRecorder/AudioRecordingPreview.tsx
|
|
52372
|
-
var
|
|
52380
|
+
var import_react192 = __toESM(require("react"));
|
|
52373
52381
|
|
|
52374
52382
|
// src/components/MediaRecorder/AudioRecorder/RecordingTimer.tsx
|
|
52375
52383
|
var import_clsx52 = __toESM(require("clsx"));
|
|
52376
|
-
var
|
|
52377
|
-
var RecordingTimer = ({ durationSeconds }) => /* @__PURE__ */
|
|
52384
|
+
var import_react191 = __toESM(require("react"));
|
|
52385
|
+
var RecordingTimer = ({ durationSeconds }) => /* @__PURE__ */ import_react191.default.createElement(
|
|
52378
52386
|
"div",
|
|
52379
52387
|
{
|
|
52380
52388
|
className: (0, import_clsx52.default)("str-chat__recording-timer", {
|
|
@@ -52396,15 +52404,15 @@ var AudioRecordingPreview = ({
|
|
|
52396
52404
|
mimeType
|
|
52397
52405
|
});
|
|
52398
52406
|
const displayedDuration = secondsElapsed || durationSeconds;
|
|
52399
|
-
return /* @__PURE__ */
|
|
52407
|
+
return /* @__PURE__ */ import_react192.default.createElement(import_react192.default.Fragment, null, /* @__PURE__ */ import_react192.default.createElement("audio", { ref: audioRef }, /* @__PURE__ */ import_react192.default.createElement("source", { src: props.src, type: mimeType })), /* @__PURE__ */ import_react192.default.createElement(
|
|
52400
52408
|
"button",
|
|
52401
52409
|
{
|
|
52402
52410
|
className: "str-chat__audio_recorder__toggle-playback-button",
|
|
52403
52411
|
"data-testid": "audio-recording-preview-toggle-play-btn",
|
|
52404
52412
|
onClick: togglePlay
|
|
52405
52413
|
},
|
|
52406
|
-
isPlaying ? /* @__PURE__ */
|
|
52407
|
-
), /* @__PURE__ */
|
|
52414
|
+
isPlaying ? /* @__PURE__ */ import_react192.default.createElement(PauseIcon2, null) : /* @__PURE__ */ import_react192.default.createElement(PlayIcon, null)
|
|
52415
|
+
), /* @__PURE__ */ import_react192.default.createElement(RecordingTimer, { durationSeconds: displayedDuration }), /* @__PURE__ */ import_react192.default.createElement("div", { className: "str-chat__wave-progress-bar__track-container" }, /* @__PURE__ */ import_react192.default.createElement(
|
|
52408
52416
|
WaveProgressBar,
|
|
52409
52417
|
{
|
|
52410
52418
|
progress,
|
|
@@ -52415,24 +52423,24 @@ var AudioRecordingPreview = ({
|
|
|
52415
52423
|
};
|
|
52416
52424
|
|
|
52417
52425
|
// src/components/MediaRecorder/AudioRecorder/AudioRecordingInProgress.tsx
|
|
52418
|
-
var
|
|
52426
|
+
var import_react194 = __toESM(require("react"));
|
|
52419
52427
|
|
|
52420
52428
|
// src/components/MessageInput/hooks/useTimeElapsed.ts
|
|
52421
|
-
var
|
|
52429
|
+
var import_react193 = require("react");
|
|
52422
52430
|
var useTimeElapsed = ({ startOnMount } = {}) => {
|
|
52423
|
-
const [secondsElapsed, setSecondsElapsed] = (0,
|
|
52424
|
-
const updateInterval = (0,
|
|
52425
|
-
const startCounter = (0,
|
|
52431
|
+
const [secondsElapsed, setSecondsElapsed] = (0, import_react193.useState)(0);
|
|
52432
|
+
const updateInterval = (0, import_react193.useRef)(void 0);
|
|
52433
|
+
const startCounter = (0, import_react193.useCallback)(() => {
|
|
52426
52434
|
if (updateInterval.current) return;
|
|
52427
52435
|
updateInterval.current = setInterval(() => {
|
|
52428
52436
|
setSecondsElapsed((prev) => prev + 1);
|
|
52429
52437
|
}, 1e3);
|
|
52430
52438
|
}, []);
|
|
52431
|
-
const stopCounter = (0,
|
|
52439
|
+
const stopCounter = (0, import_react193.useCallback)(() => {
|
|
52432
52440
|
clearInterval(updateInterval.current);
|
|
52433
52441
|
updateInterval.current = void 0;
|
|
52434
52442
|
}, []);
|
|
52435
|
-
(0,
|
|
52443
|
+
(0, import_react193.useEffect)(() => {
|
|
52436
52444
|
if (!startOnMount) return;
|
|
52437
52445
|
startCounter();
|
|
52438
52446
|
return () => {
|
|
@@ -52451,8 +52459,8 @@ var AudioRecordingWaveform = ({ maxDataPointsDrawn = 100 }) => {
|
|
|
52451
52459
|
const {
|
|
52452
52460
|
recordingController: { recorder }
|
|
52453
52461
|
} = useMessageInputContext();
|
|
52454
|
-
const [amplitudes, setAmplitudes] = (0,
|
|
52455
|
-
(0,
|
|
52462
|
+
const [amplitudes, setAmplitudes] = (0, import_react194.useState)([]);
|
|
52463
|
+
(0, import_react194.useEffect)(() => {
|
|
52456
52464
|
if (!recorder?.amplitudeRecorder) return;
|
|
52457
52465
|
const amplitudesSubscription = recorder.amplitudeRecorder.amplitudes.subscribe(setAmplitudes);
|
|
52458
52466
|
return () => {
|
|
@@ -52460,7 +52468,7 @@ var AudioRecordingWaveform = ({ maxDataPointsDrawn = 100 }) => {
|
|
|
52460
52468
|
};
|
|
52461
52469
|
}, [recorder]);
|
|
52462
52470
|
if (!recorder) return null;
|
|
52463
|
-
return /* @__PURE__ */
|
|
52471
|
+
return /* @__PURE__ */ import_react194.default.createElement("div", { className: "str-chat__waveform-box-container" }, /* @__PURE__ */ import_react194.default.createElement("div", { className: "str-chat__audio_recorder__waveform-box" }, amplitudes.slice(-maxDataPointsDrawn).map((amplitude, i) => /* @__PURE__ */ import_react194.default.createElement(
|
|
52464
52472
|
"div",
|
|
52465
52473
|
{
|
|
52466
52474
|
className: "str-chat__wave-progress-bar__amplitude-bar",
|
|
@@ -52476,7 +52484,7 @@ var AudioRecordingInProgress = () => {
|
|
|
52476
52484
|
const {
|
|
52477
52485
|
recordingController: { recorder }
|
|
52478
52486
|
} = useMessageInputContext();
|
|
52479
|
-
(0,
|
|
52487
|
+
(0, import_react194.useEffect)(() => {
|
|
52480
52488
|
if (!recorder?.mediaRecorder) return;
|
|
52481
52489
|
const { mediaRecorder } = recorder;
|
|
52482
52490
|
if (mediaRecorder.state === "recording") {
|
|
@@ -52493,7 +52501,7 @@ var AudioRecordingInProgress = () => {
|
|
|
52493
52501
|
mediaRecorder.removeEventListener("pause", stopCounter);
|
|
52494
52502
|
};
|
|
52495
52503
|
}, [recorder, startCounter, stopCounter]);
|
|
52496
|
-
return /* @__PURE__ */
|
|
52504
|
+
return /* @__PURE__ */ import_react194.default.createElement(import_react194.default.Fragment, null, /* @__PURE__ */ import_react194.default.createElement(RecordingTimer, { durationSeconds: secondsElapsed }), /* @__PURE__ */ import_react194.default.createElement(AudioRecordingWaveform, null));
|
|
52497
52505
|
};
|
|
52498
52506
|
|
|
52499
52507
|
// src/components/MediaRecorder/AudioRecorder/AudioRecorder.tsx
|
|
@@ -52502,7 +52510,7 @@ var AudioRecorder = () => {
|
|
|
52502
52510
|
recordingController: { completeRecording, recorder, recording, recordingState }
|
|
52503
52511
|
} = useMessageInputContext();
|
|
52504
52512
|
const isUploadingFile = recording?.localMetadata?.uploadState === "uploading";
|
|
52505
|
-
const state = (0,
|
|
52513
|
+
const state = (0, import_react195.useMemo)(
|
|
52506
52514
|
() => ({
|
|
52507
52515
|
paused: recordingState === "paused" /* PAUSED */,
|
|
52508
52516
|
recording: recordingState === "recording" /* RECORDING */,
|
|
@@ -52511,7 +52519,7 @@ var AudioRecorder = () => {
|
|
|
52511
52519
|
[recordingState]
|
|
52512
52520
|
);
|
|
52513
52521
|
if (!recorder) return null;
|
|
52514
|
-
return /* @__PURE__ */
|
|
52522
|
+
return /* @__PURE__ */ import_react195.default.createElement("div", { className: "str-chat__audio_recorder-container" }, /* @__PURE__ */ import_react195.default.createElement("div", { className: "str-chat__audio_recorder", "data-testid": "audio-recorder" }, /* @__PURE__ */ import_react195.default.createElement(
|
|
52515
52523
|
"button",
|
|
52516
52524
|
{
|
|
52517
52525
|
className: "str-chat__audio_recorder__cancel-button",
|
|
@@ -52519,8 +52527,8 @@ var AudioRecorder = () => {
|
|
|
52519
52527
|
disabled: isUploadingFile,
|
|
52520
52528
|
onClick: recorder.cancel
|
|
52521
52529
|
},
|
|
52522
|
-
/* @__PURE__ */
|
|
52523
|
-
), state.stopped && recording?.asset_url ? /* @__PURE__ */
|
|
52530
|
+
/* @__PURE__ */ import_react195.default.createElement(BinIcon, null)
|
|
52531
|
+
), state.stopped && recording?.asset_url ? /* @__PURE__ */ import_react195.default.createElement(
|
|
52524
52532
|
AudioRecordingPreview,
|
|
52525
52533
|
{
|
|
52526
52534
|
durationSeconds: recording.duration ?? 0,
|
|
@@ -52528,22 +52536,22 @@ var AudioRecorder = () => {
|
|
|
52528
52536
|
src: recording.asset_url,
|
|
52529
52537
|
waveformData: recording.waveform_data
|
|
52530
52538
|
}
|
|
52531
|
-
) : state.paused || state.recording ? /* @__PURE__ */
|
|
52539
|
+
) : state.paused || state.recording ? /* @__PURE__ */ import_react195.default.createElement(AudioRecordingInProgress, null) : null, state.paused && /* @__PURE__ */ import_react195.default.createElement(
|
|
52532
52540
|
"button",
|
|
52533
52541
|
{
|
|
52534
52542
|
className: "str-chat__audio_recorder__resume-recording-button",
|
|
52535
52543
|
onClick: recorder.resume
|
|
52536
52544
|
},
|
|
52537
|
-
/* @__PURE__ */
|
|
52538
|
-
), state.recording && /* @__PURE__ */
|
|
52545
|
+
/* @__PURE__ */ import_react195.default.createElement(MicIcon, null)
|
|
52546
|
+
), state.recording && /* @__PURE__ */ import_react195.default.createElement(
|
|
52539
52547
|
"button",
|
|
52540
52548
|
{
|
|
52541
52549
|
className: "str-chat__audio_recorder__pause-recording-button",
|
|
52542
52550
|
"data-testid": "pause-recording-audio-button",
|
|
52543
52551
|
onClick: recorder.pause
|
|
52544
52552
|
},
|
|
52545
|
-
/* @__PURE__ */
|
|
52546
|
-
), state.stopped ? /* @__PURE__ */
|
|
52553
|
+
/* @__PURE__ */ import_react195.default.createElement(PauseIcon2, null)
|
|
52554
|
+
), state.stopped ? /* @__PURE__ */ import_react195.default.createElement(
|
|
52547
52555
|
"button",
|
|
52548
52556
|
{
|
|
52549
52557
|
className: "str-chat__audio_recorder__complete-button",
|
|
@@ -52551,21 +52559,21 @@ var AudioRecorder = () => {
|
|
|
52551
52559
|
disabled: isUploadingFile,
|
|
52552
52560
|
onClick: completeRecording
|
|
52553
52561
|
},
|
|
52554
|
-
isUploadingFile ? /* @__PURE__ */
|
|
52555
|
-
) : /* @__PURE__ */
|
|
52562
|
+
isUploadingFile ? /* @__PURE__ */ import_react195.default.createElement(LoadingIndicatorIcon, null) : /* @__PURE__ */ import_react195.default.createElement(SendIcon, null)
|
|
52563
|
+
) : /* @__PURE__ */ import_react195.default.createElement(
|
|
52556
52564
|
"button",
|
|
52557
52565
|
{
|
|
52558
52566
|
className: "str-chat__audio_recorder__stop-button",
|
|
52559
52567
|
"data-testid": "audio-recorder-stop-button",
|
|
52560
52568
|
onClick: recorder.stop
|
|
52561
52569
|
},
|
|
52562
|
-
/* @__PURE__ */
|
|
52570
|
+
/* @__PURE__ */ import_react195.default.createElement(CheckSignIcon, null)
|
|
52563
52571
|
)));
|
|
52564
52572
|
};
|
|
52565
52573
|
|
|
52566
52574
|
// src/components/MediaRecorder/AudioRecorder/AudioRecordingButtons.tsx
|
|
52567
|
-
var
|
|
52568
|
-
var StartRecordingAudioButton = (props) => /* @__PURE__ */
|
|
52575
|
+
var import_react196 = __toESM(require("react"));
|
|
52576
|
+
var StartRecordingAudioButton = (props) => /* @__PURE__ */ import_react196.default.createElement(
|
|
52569
52577
|
"button",
|
|
52570
52578
|
{
|
|
52571
52579
|
"aria-label": "Start recording audio",
|
|
@@ -52573,7 +52581,7 @@ var StartRecordingAudioButton = (props) => /* @__PURE__ */ import_react195.defau
|
|
|
52573
52581
|
"data-testid": "start-recording-audio-button",
|
|
52574
52582
|
...props
|
|
52575
52583
|
},
|
|
52576
|
-
/* @__PURE__ */
|
|
52584
|
+
/* @__PURE__ */ import_react196.default.createElement(MicIcon, null)
|
|
52577
52585
|
);
|
|
52578
52586
|
|
|
52579
52587
|
// src/components/MessageInput/AttachmentPreviewList/VoiceRecordingPreview.tsx
|
|
@@ -52585,13 +52593,13 @@ var VoiceRecordingPreview = ({
|
|
|
52585
52593
|
const { audioRef, isPlaying, secondsElapsed, togglePlay } = useAudioController({
|
|
52586
52594
|
mimeType: attachment.mime_type
|
|
52587
52595
|
});
|
|
52588
|
-
return /* @__PURE__ */
|
|
52596
|
+
return /* @__PURE__ */ import_react197.default.createElement(
|
|
52589
52597
|
"div",
|
|
52590
52598
|
{
|
|
52591
52599
|
className: "str-chat__attachment-preview-voice-recording",
|
|
52592
52600
|
"data-testid": "attachment-preview-voice-recording"
|
|
52593
52601
|
},
|
|
52594
|
-
/* @__PURE__ */
|
|
52602
|
+
/* @__PURE__ */ import_react197.default.createElement("audio", { ref: audioRef }, /* @__PURE__ */ import_react197.default.createElement(
|
|
52595
52603
|
"source",
|
|
52596
52604
|
{
|
|
52597
52605
|
"data-testid": "audio-source",
|
|
@@ -52599,8 +52607,8 @@ var VoiceRecordingPreview = ({
|
|
|
52599
52607
|
type: attachment.mime_type
|
|
52600
52608
|
}
|
|
52601
52609
|
)),
|
|
52602
|
-
/* @__PURE__ */
|
|
52603
|
-
/* @__PURE__ */
|
|
52610
|
+
/* @__PURE__ */ import_react197.default.createElement(PlayButton, { isPlaying, onClick: togglePlay }),
|
|
52611
|
+
/* @__PURE__ */ import_react197.default.createElement(
|
|
52604
52612
|
"button",
|
|
52605
52613
|
{
|
|
52606
52614
|
className: "str-chat__attachment-preview-delete",
|
|
@@ -52608,38 +52616,38 @@ var VoiceRecordingPreview = ({
|
|
|
52608
52616
|
disabled: attachment.localMetadata?.uploadState === "uploading",
|
|
52609
52617
|
onClick: () => attachment.localMetadata?.id && removeAttachments([attachment.localMetadata.id])
|
|
52610
52618
|
},
|
|
52611
|
-
/* @__PURE__ */
|
|
52619
|
+
/* @__PURE__ */ import_react197.default.createElement(CloseIcon, null)
|
|
52612
52620
|
),
|
|
52613
|
-
attachment.localMetadata?.uploadState === "failed" && !!handleRetry && /* @__PURE__ */
|
|
52621
|
+
attachment.localMetadata?.uploadState === "failed" && !!handleRetry && /* @__PURE__ */ import_react197.default.createElement(
|
|
52614
52622
|
"button",
|
|
52615
52623
|
{
|
|
52616
52624
|
className: "str-chat__attachment-preview-error str-chat__attachment-preview-error-file",
|
|
52617
52625
|
"data-testid": "file-preview-item-retry-button",
|
|
52618
52626
|
onClick: () => handleRetry(attachment)
|
|
52619
52627
|
},
|
|
52620
|
-
/* @__PURE__ */
|
|
52628
|
+
/* @__PURE__ */ import_react197.default.createElement(RetryIcon, null)
|
|
52621
52629
|
),
|
|
52622
|
-
/* @__PURE__ */
|
|
52623
|
-
/* @__PURE__ */
|
|
52630
|
+
/* @__PURE__ */ import_react197.default.createElement("div", { className: "str-chat__attachment-preview-metadata" }, /* @__PURE__ */ import_react197.default.createElement("div", { className: "str-chat__attachment-preview-file-name", title: attachment.title }, attachment.title), typeof attachment.duration !== "undefined" && /* @__PURE__ */ import_react197.default.createElement(RecordingTimer, { durationSeconds: secondsElapsed || attachment.duration }), attachment.localMetadata?.uploadState === "uploading" && /* @__PURE__ */ import_react197.default.createElement(LoadingIndicatorIcon, { size: 17 })),
|
|
52631
|
+
/* @__PURE__ */ import_react197.default.createElement("div", { className: "str-chat__attachment-preview-file-icon" }, /* @__PURE__ */ import_react197.default.createElement(FileIcon, { filename: attachment.title, mimeType: attachment.mime_type }))
|
|
52624
52632
|
);
|
|
52625
52633
|
};
|
|
52626
52634
|
|
|
52627
52635
|
// src/components/MessageInput/AttachmentPreviewList/FileAttachmentPreview.tsx
|
|
52628
|
-
var
|
|
52636
|
+
var import_react198 = __toESM(require("react"));
|
|
52629
52637
|
var FileAttachmentPreview = ({
|
|
52630
52638
|
attachment,
|
|
52631
52639
|
handleRetry,
|
|
52632
52640
|
removeAttachments
|
|
52633
52641
|
}) => {
|
|
52634
52642
|
const { t: t2 } = useTranslationContext("FilePreview");
|
|
52635
|
-
return /* @__PURE__ */
|
|
52643
|
+
return /* @__PURE__ */ import_react198.default.createElement(
|
|
52636
52644
|
"div",
|
|
52637
52645
|
{
|
|
52638
52646
|
className: "str-chat__attachment-preview-file",
|
|
52639
52647
|
"data-testid": "attachment-preview-file"
|
|
52640
52648
|
},
|
|
52641
|
-
/* @__PURE__ */
|
|
52642
|
-
/* @__PURE__ */
|
|
52649
|
+
/* @__PURE__ */ import_react198.default.createElement("div", { className: "str-chat__attachment-preview-file-icon" }, /* @__PURE__ */ import_react198.default.createElement(FileIcon, { filename: attachment.title, mimeType: attachment.mime_type })),
|
|
52650
|
+
/* @__PURE__ */ import_react198.default.createElement(
|
|
52643
52651
|
"button",
|
|
52644
52652
|
{
|
|
52645
52653
|
"aria-label": t2("aria/Remove attachment"),
|
|
@@ -52648,18 +52656,18 @@ var FileAttachmentPreview = ({
|
|
|
52648
52656
|
disabled: attachment.localMetadata?.uploadState === "uploading",
|
|
52649
52657
|
onClick: () => attachment.localMetadata?.id && removeAttachments([attachment.localMetadata?.id])
|
|
52650
52658
|
},
|
|
52651
|
-
/* @__PURE__ */
|
|
52659
|
+
/* @__PURE__ */ import_react198.default.createElement(CloseIcon, null)
|
|
52652
52660
|
),
|
|
52653
|
-
attachment.localMetadata?.uploadState === "failed" && !!handleRetry && /* @__PURE__ */
|
|
52661
|
+
attachment.localMetadata?.uploadState === "failed" && !!handleRetry && /* @__PURE__ */ import_react198.default.createElement(
|
|
52654
52662
|
"button",
|
|
52655
52663
|
{
|
|
52656
52664
|
className: "str-chat__attachment-preview-error str-chat__attachment-preview-error-file",
|
|
52657
52665
|
"data-testid": "file-preview-item-retry-button",
|
|
52658
52666
|
onClick: () => handleRetry(attachment)
|
|
52659
52667
|
},
|
|
52660
|
-
/* @__PURE__ */
|
|
52668
|
+
/* @__PURE__ */ import_react198.default.createElement(RetryIcon, null)
|
|
52661
52669
|
),
|
|
52662
|
-
/* @__PURE__ */
|
|
52670
|
+
/* @__PURE__ */ import_react198.default.createElement("div", { className: "str-chat__attachment-preview-file-end" }, /* @__PURE__ */ import_react198.default.createElement("div", { className: "str-chat__attachment-preview-file-name", title: attachment.title }, attachment.title), attachment.localMetadata?.uploadState === "finished" && !!attachment.asset_url && /* @__PURE__ */ import_react198.default.createElement(
|
|
52663
52671
|
"a",
|
|
52664
52672
|
{
|
|
52665
52673
|
"aria-label": t2("aria/Download attachment"),
|
|
@@ -52670,14 +52678,14 @@ var FileAttachmentPreview = ({
|
|
|
52670
52678
|
target: "_blank",
|
|
52671
52679
|
title: t2("Download attachment {{ name }}", { name: attachment.title })
|
|
52672
52680
|
},
|
|
52673
|
-
/* @__PURE__ */
|
|
52674
|
-
), attachment.localMetadata?.uploadState === "uploading" && /* @__PURE__ */
|
|
52681
|
+
/* @__PURE__ */ import_react198.default.createElement(DownloadIcon2, null)
|
|
52682
|
+
), attachment.localMetadata?.uploadState === "uploading" && /* @__PURE__ */ import_react198.default.createElement(LoadingIndicatorIcon, { size: 17 }))
|
|
52675
52683
|
);
|
|
52676
52684
|
};
|
|
52677
52685
|
|
|
52678
52686
|
// src/components/MessageInput/AttachmentPreviewList/ImageAttachmentPreview.tsx
|
|
52679
52687
|
var import_clsx53 = __toESM(require("clsx"));
|
|
52680
|
-
var
|
|
52688
|
+
var import_react199 = __toESM(require("react"));
|
|
52681
52689
|
var ImageAttachmentPreview = ({
|
|
52682
52690
|
attachment,
|
|
52683
52691
|
handleRetry,
|
|
@@ -52685,11 +52693,11 @@ var ImageAttachmentPreview = ({
|
|
|
52685
52693
|
}) => {
|
|
52686
52694
|
const { t: t2 } = useTranslationContext("ImagePreviewItem");
|
|
52687
52695
|
const { BaseImage: BaseImage3 = BaseImage } = useComponentContext("ImagePreview");
|
|
52688
|
-
const [previewError, setPreviewError] = (0,
|
|
52696
|
+
const [previewError, setPreviewError] = (0, import_react199.useState)(false);
|
|
52689
52697
|
const { id, uploadState } = attachment.localMetadata ?? {};
|
|
52690
|
-
const handleLoadError = (0,
|
|
52698
|
+
const handleLoadError = (0, import_react199.useCallback)(() => setPreviewError(true), []);
|
|
52691
52699
|
const assetUrl = attachment.image_url || attachment.localMetadata.previewUri;
|
|
52692
|
-
return /* @__PURE__ */
|
|
52700
|
+
return /* @__PURE__ */ import_react199.default.createElement(
|
|
52693
52701
|
"div",
|
|
52694
52702
|
{
|
|
52695
52703
|
className: (0, import_clsx53.default)("str-chat__attachment-preview-image", {
|
|
@@ -52697,7 +52705,7 @@ var ImageAttachmentPreview = ({
|
|
|
52697
52705
|
}),
|
|
52698
52706
|
"data-testid": "attachment-preview-image"
|
|
52699
52707
|
},
|
|
52700
|
-
/* @__PURE__ */
|
|
52708
|
+
/* @__PURE__ */ import_react199.default.createElement(
|
|
52701
52709
|
"button",
|
|
52702
52710
|
{
|
|
52703
52711
|
"aria-label": t2("aria/Remove attachment"),
|
|
@@ -52706,19 +52714,19 @@ var ImageAttachmentPreview = ({
|
|
|
52706
52714
|
disabled: uploadState === "uploading",
|
|
52707
52715
|
onClick: () => id && removeAttachments([id])
|
|
52708
52716
|
},
|
|
52709
|
-
/* @__PURE__ */
|
|
52717
|
+
/* @__PURE__ */ import_react199.default.createElement(CloseIcon, null)
|
|
52710
52718
|
),
|
|
52711
|
-
uploadState === "failed" && /* @__PURE__ */
|
|
52719
|
+
uploadState === "failed" && /* @__PURE__ */ import_react199.default.createElement(
|
|
52712
52720
|
"button",
|
|
52713
52721
|
{
|
|
52714
52722
|
className: "str-chat__attachment-preview-error str-chat__attachment-preview-error-image",
|
|
52715
52723
|
"data-testid": "image-preview-item-retry-button",
|
|
52716
52724
|
onClick: () => handleRetry(attachment)
|
|
52717
52725
|
},
|
|
52718
|
-
/* @__PURE__ */
|
|
52726
|
+
/* @__PURE__ */ import_react199.default.createElement(RetryIcon, null)
|
|
52719
52727
|
),
|
|
52720
|
-
uploadState === "uploading" && /* @__PURE__ */
|
|
52721
|
-
assetUrl && /* @__PURE__ */
|
|
52728
|
+
uploadState === "uploading" && /* @__PURE__ */ import_react199.default.createElement("div", { className: "str-chat__attachment-preview-image-loading" }, /* @__PURE__ */ import_react199.default.createElement(LoadingIndicatorIcon, { size: 17 })),
|
|
52729
|
+
assetUrl && /* @__PURE__ */ import_react199.default.createElement(
|
|
52722
52730
|
BaseImage3,
|
|
52723
52731
|
{
|
|
52724
52732
|
alt: attachment.fallback,
|
|
@@ -52741,7 +52749,7 @@ var AttachmentPreviewList = ({
|
|
|
52741
52749
|
VoiceRecordingPreview: VoiceRecordingPreview2 = VoiceRecordingPreview
|
|
52742
52750
|
}) => {
|
|
52743
52751
|
const { attachments, removeAttachments, uploadAttachment } = useMessageInputContext("AttachmentPreviewList");
|
|
52744
|
-
return /* @__PURE__ */
|
|
52752
|
+
return /* @__PURE__ */ import_react200.default.createElement("div", { className: "str-chat__attachment-preview-list" }, /* @__PURE__ */ import_react200.default.createElement(
|
|
52745
52753
|
"div",
|
|
52746
52754
|
{
|
|
52747
52755
|
className: "str-chat__attachment-list-scroll-container",
|
|
@@ -52750,7 +52758,7 @@ var AttachmentPreviewList = ({
|
|
|
52750
52758
|
attachments.map((attachment) => {
|
|
52751
52759
|
if (isScrapedContent(attachment)) return null;
|
|
52752
52760
|
if (isLocalVoiceRecordingAttachment(attachment)) {
|
|
52753
|
-
return /* @__PURE__ */
|
|
52761
|
+
return /* @__PURE__ */ import_react200.default.createElement(
|
|
52754
52762
|
VoiceRecordingPreview2,
|
|
52755
52763
|
{
|
|
52756
52764
|
attachment,
|
|
@@ -52760,7 +52768,7 @@ var AttachmentPreviewList = ({
|
|
|
52760
52768
|
}
|
|
52761
52769
|
);
|
|
52762
52770
|
} else if (isLocalAudioAttachment(attachment)) {
|
|
52763
|
-
return /* @__PURE__ */
|
|
52771
|
+
return /* @__PURE__ */ import_react200.default.createElement(
|
|
52764
52772
|
AudioAttachmentPreview,
|
|
52765
52773
|
{
|
|
52766
52774
|
attachment,
|
|
@@ -52770,7 +52778,7 @@ var AttachmentPreviewList = ({
|
|
|
52770
52778
|
}
|
|
52771
52779
|
);
|
|
52772
52780
|
} else if (isLocalMediaAttachment(attachment)) {
|
|
52773
|
-
return /* @__PURE__ */
|
|
52781
|
+
return /* @__PURE__ */ import_react200.default.createElement(
|
|
52774
52782
|
VideoAttachmentPreview,
|
|
52775
52783
|
{
|
|
52776
52784
|
attachment,
|
|
@@ -52780,7 +52788,7 @@ var AttachmentPreviewList = ({
|
|
|
52780
52788
|
}
|
|
52781
52789
|
);
|
|
52782
52790
|
} else if (isLocalImageAttachment(attachment)) {
|
|
52783
|
-
return /* @__PURE__ */
|
|
52791
|
+
return /* @__PURE__ */ import_react200.default.createElement(
|
|
52784
52792
|
ImageAttachmentPreview2,
|
|
52785
52793
|
{
|
|
52786
52794
|
attachment,
|
|
@@ -52790,7 +52798,7 @@ var AttachmentPreviewList = ({
|
|
|
52790
52798
|
}
|
|
52791
52799
|
);
|
|
52792
52800
|
} else if (isLocalFileAttachment(attachment)) {
|
|
52793
|
-
return /* @__PURE__ */
|
|
52801
|
+
return /* @__PURE__ */ import_react200.default.createElement(
|
|
52794
52802
|
FileAttachmentPreview2,
|
|
52795
52803
|
{
|
|
52796
52804
|
attachment,
|
|
@@ -52800,7 +52808,7 @@ var AttachmentPreviewList = ({
|
|
|
52800
52808
|
}
|
|
52801
52809
|
);
|
|
52802
52810
|
} else if (isLocalAttachment(attachment)) {
|
|
52803
|
-
return /* @__PURE__ */
|
|
52811
|
+
return /* @__PURE__ */ import_react200.default.createElement(
|
|
52804
52812
|
UnsupportedAttachmentPreview2,
|
|
52805
52813
|
{
|
|
52806
52814
|
attachment,
|
|
@@ -52816,13 +52824,13 @@ var AttachmentPreviewList = ({
|
|
|
52816
52824
|
};
|
|
52817
52825
|
|
|
52818
52826
|
// src/components/MessageInput/CooldownTimer.tsx
|
|
52819
|
-
var
|
|
52827
|
+
var import_react202 = __toESM(require("react"));
|
|
52820
52828
|
|
|
52821
52829
|
// src/components/MessageInput/hooks/useTimer.ts
|
|
52822
|
-
var
|
|
52830
|
+
var import_react201 = require("react");
|
|
52823
52831
|
var useTimer = ({ startFrom }) => {
|
|
52824
|
-
const [secondsLeft, setSecondsLeft] = (0,
|
|
52825
|
-
(0,
|
|
52832
|
+
const [secondsLeft, setSecondsLeft] = (0, import_react201.useState)();
|
|
52833
|
+
(0, import_react201.useEffect)(() => {
|
|
52826
52834
|
let countdownTimeout;
|
|
52827
52835
|
if (typeof secondsLeft === "number" && secondsLeft > 0) {
|
|
52828
52836
|
countdownTimeout = setTimeout(() => {
|
|
@@ -52833,7 +52841,7 @@ var useTimer = ({ startFrom }) => {
|
|
|
52833
52841
|
clearTimeout(countdownTimeout);
|
|
52834
52842
|
};
|
|
52835
52843
|
}, [secondsLeft]);
|
|
52836
|
-
(0,
|
|
52844
|
+
(0, import_react201.useEffect)(() => {
|
|
52837
52845
|
setSecondsLeft(startFrom ?? 0);
|
|
52838
52846
|
}, [startFrom]);
|
|
52839
52847
|
return secondsLeft;
|
|
@@ -52842,11 +52850,11 @@ var useTimer = ({ startFrom }) => {
|
|
|
52842
52850
|
// src/components/MessageInput/CooldownTimer.tsx
|
|
52843
52851
|
var CooldownTimer = ({ cooldownInterval }) => {
|
|
52844
52852
|
const secondsLeft = useTimer({ startFrom: cooldownInterval });
|
|
52845
|
-
return /* @__PURE__ */
|
|
52853
|
+
return /* @__PURE__ */ import_react202.default.createElement("div", { className: "str-chat__message-input-cooldown", "data-testid": "cooldown-timer" }, secondsLeft);
|
|
52846
52854
|
};
|
|
52847
52855
|
|
|
52848
52856
|
// src/components/MessageInput/DefaultTriggerProvider.tsx
|
|
52849
|
-
var
|
|
52857
|
+
var import_react205 = __toESM(require("react"));
|
|
52850
52858
|
|
|
52851
52859
|
// src/components/MessageInput/hooks/useCommandTrigger.ts
|
|
52852
52860
|
var useCommandTrigger = () => {
|
|
@@ -52916,7 +52924,7 @@ var useCommandTrigger = () => {
|
|
|
52916
52924
|
};
|
|
52917
52925
|
|
|
52918
52926
|
// src/components/EmoticonItem/EmoticonItem.tsx
|
|
52919
|
-
var
|
|
52927
|
+
var import_react203 = __toESM(require("react"));
|
|
52920
52928
|
var UnMemoizedEmoticonItem = (props) => {
|
|
52921
52929
|
const { entity } = props;
|
|
52922
52930
|
const hasEntity = Object.keys(entity).length;
|
|
@@ -52924,12 +52932,12 @@ var UnMemoizedEmoticonItem = (props) => {
|
|
|
52924
52932
|
const renderName = () => {
|
|
52925
52933
|
if (!hasEntity) return null;
|
|
52926
52934
|
return hasEntity && itemParts.parts.map(
|
|
52927
|
-
(part, i) => part.toLowerCase() === itemParts.match.toLowerCase() ? /* @__PURE__ */
|
|
52935
|
+
(part, i) => part.toLowerCase() === itemParts.match.toLowerCase() ? /* @__PURE__ */ import_react203.default.createElement("span", { className: "str-chat__emoji-item--highlight", key: `part-${i}` }, part) : /* @__PURE__ */ import_react203.default.createElement("span", { className: "str-chat__emoji-item--part", key: `part-${i}` }, part)
|
|
52928
52936
|
);
|
|
52929
52937
|
};
|
|
52930
|
-
return /* @__PURE__ */
|
|
52938
|
+
return /* @__PURE__ */ import_react203.default.createElement("div", { className: "str-chat__emoji-item" }, /* @__PURE__ */ import_react203.default.createElement("span", { className: "str-chat__emoji-item--entity" }, entity.native), /* @__PURE__ */ import_react203.default.createElement("span", { className: "str-chat__emoji-item--name" }, renderName()));
|
|
52931
52939
|
};
|
|
52932
|
-
var EmoticonItem =
|
|
52940
|
+
var EmoticonItem = import_react203.default.memo(
|
|
52933
52941
|
UnMemoizedEmoticonItem
|
|
52934
52942
|
);
|
|
52935
52943
|
|
|
@@ -52959,7 +52967,7 @@ var useEmojiTrigger = (emojiSearchIndex) => ({
|
|
|
52959
52967
|
});
|
|
52960
52968
|
|
|
52961
52969
|
// src/components/MessageInput/hooks/useUserTrigger.ts
|
|
52962
|
-
var
|
|
52970
|
+
var import_react204 = require("react");
|
|
52963
52971
|
var import_lodash20 = __toESM(require("lodash.throttle"));
|
|
52964
52972
|
var useUserTrigger = (params) => {
|
|
52965
52973
|
const {
|
|
@@ -52969,12 +52977,12 @@ var useUserTrigger = (params) => {
|
|
|
52969
52977
|
onSelectUser,
|
|
52970
52978
|
useMentionsTransliteration
|
|
52971
52979
|
} = params;
|
|
52972
|
-
const [searching, setSearching] = (0,
|
|
52980
|
+
const [searching, setSearching] = (0, import_react204.useState)(false);
|
|
52973
52981
|
const { client, mutes } = useChatContext("useUserTrigger");
|
|
52974
52982
|
const { channel } = useChannelStateContext("useUserTrigger");
|
|
52975
52983
|
const { members } = channel.state;
|
|
52976
52984
|
const { watchers } = channel.state;
|
|
52977
|
-
const getMembersAndWatchers = (0,
|
|
52985
|
+
const getMembersAndWatchers = (0, import_react204.useCallback)(() => {
|
|
52978
52986
|
const memberUsers = members ? Object.values(members).map(({ user }) => user) : [];
|
|
52979
52987
|
const watcherUsers = watchers ? Object.values(watchers) : [];
|
|
52980
52988
|
const users = [...memberUsers, ...watcherUsers];
|
|
@@ -52986,7 +52994,7 @@ var useUserTrigger = (params) => {
|
|
|
52986
52994
|
});
|
|
52987
52995
|
return Object.values(uniqueUsers);
|
|
52988
52996
|
}, [members, watchers]);
|
|
52989
|
-
const queryMembersThrottled = (0,
|
|
52997
|
+
const queryMembersThrottled = (0, import_react204.useCallback)(
|
|
52990
52998
|
(0, import_lodash20.default)(
|
|
52991
52999
|
async (query, onReady) => {
|
|
52992
53000
|
try {
|
|
@@ -53106,21 +53114,21 @@ var DefaultTriggerProvider = ({
|
|
|
53106
53114
|
...currentValue,
|
|
53107
53115
|
autocompleteTriggers: defaultAutocompleteTriggers
|
|
53108
53116
|
};
|
|
53109
|
-
return /* @__PURE__ */
|
|
53117
|
+
return /* @__PURE__ */ import_react205.default.createElement(MessageInputContextProvider, { value: newValue }, children);
|
|
53110
53118
|
};
|
|
53111
53119
|
|
|
53112
53120
|
// src/components/MessageInput/EditMessageForm.tsx
|
|
53113
|
-
var
|
|
53121
|
+
var import_react218 = __toESM(require("react"));
|
|
53114
53122
|
|
|
53115
53123
|
// src/components/MessageInput/MessageInputFlat.tsx
|
|
53116
|
-
var
|
|
53124
|
+
var import_react217 = __toESM(require("react"));
|
|
53117
53125
|
|
|
53118
53126
|
// src/components/MessageInput/SendButton.tsx
|
|
53119
|
-
var
|
|
53127
|
+
var import_react206 = __toESM(require("react"));
|
|
53120
53128
|
var SendButton = ({
|
|
53121
53129
|
sendMessage,
|
|
53122
53130
|
...rest
|
|
53123
|
-
}) => /* @__PURE__ */
|
|
53131
|
+
}) => /* @__PURE__ */ import_react206.default.createElement(
|
|
53124
53132
|
"button",
|
|
53125
53133
|
{
|
|
53126
53134
|
"aria-label": "Send",
|
|
@@ -53130,17 +53138,17 @@ var SendButton = ({
|
|
|
53130
53138
|
type: "button",
|
|
53131
53139
|
...rest
|
|
53132
53140
|
},
|
|
53133
|
-
/* @__PURE__ */
|
|
53141
|
+
/* @__PURE__ */ import_react206.default.createElement(SendIcon, null)
|
|
53134
53142
|
);
|
|
53135
53143
|
|
|
53136
53144
|
// src/components/MessageInput/StopAIGenerationButton.tsx
|
|
53137
|
-
var
|
|
53145
|
+
var import_react207 = __toESM(require("react"));
|
|
53138
53146
|
var StopAIGenerationButton = ({
|
|
53139
53147
|
onClick,
|
|
53140
53148
|
...restProps
|
|
53141
53149
|
}) => {
|
|
53142
53150
|
const { t: t2 } = useTranslationContext();
|
|
53143
|
-
return /* @__PURE__ */
|
|
53151
|
+
return /* @__PURE__ */ import_react207.default.createElement(
|
|
53144
53152
|
"button",
|
|
53145
53153
|
{
|
|
53146
53154
|
"aria-label": t2("aria/Stop AI Generation"),
|
|
@@ -53153,21 +53161,21 @@ var StopAIGenerationButton = ({
|
|
|
53153
53161
|
};
|
|
53154
53162
|
|
|
53155
53163
|
// src/components/MessageInput/QuotedMessagePreview.tsx
|
|
53156
|
-
var
|
|
53164
|
+
var import_react211 = __toESM(require("react"));
|
|
53157
53165
|
|
|
53158
53166
|
// src/components/Message/FixedHeightMessage.tsx
|
|
53159
|
-
var
|
|
53167
|
+
var import_react209 = __toESM(require("react"));
|
|
53160
53168
|
|
|
53161
53169
|
// src/components/MML/MML.tsx
|
|
53162
|
-
var
|
|
53163
|
-
var MMLReact =
|
|
53170
|
+
var import_react208 = __toESM(require("react"));
|
|
53171
|
+
var MMLReact = import_react208.default.lazy(async () => {
|
|
53164
53172
|
const mml = await Promise.resolve().then(() => __toESM(require_dist2()));
|
|
53165
53173
|
return { default: mml.MML };
|
|
53166
53174
|
});
|
|
53167
53175
|
var MML = (props) => {
|
|
53168
53176
|
const { actionHandler, align = "right", source } = props;
|
|
53169
53177
|
const { theme } = useChatContext("MML");
|
|
53170
|
-
return /* @__PURE__ */
|
|
53178
|
+
return /* @__PURE__ */ import_react208.default.createElement(import_react208.Suspense, { fallback: null }, /* @__PURE__ */ import_react208.default.createElement(
|
|
53171
53179
|
MMLReact,
|
|
53172
53180
|
{
|
|
53173
53181
|
className: `mml-align-${align}`,
|
|
@@ -53205,24 +53213,24 @@ var UnMemoizedFixedHeightMessage = (props) => {
|
|
|
53205
53213
|
const handleDelete2 = useDeleteHandler(message);
|
|
53206
53214
|
const role = useUserRole(message);
|
|
53207
53215
|
const messageTextToRender = message?.i18n?.[`${userLanguage}_text`] || message?.text;
|
|
53208
|
-
const renderedText = (0,
|
|
53216
|
+
const renderedText = (0, import_react209.useMemo)(
|
|
53209
53217
|
() => renderText(messageTextToRender, message.mentioned_users),
|
|
53210
53218
|
[message.mentioned_users, messageTextToRender]
|
|
53211
53219
|
);
|
|
53212
53220
|
const userId = message.user?.id || "";
|
|
53213
|
-
const userColor = (0,
|
|
53214
|
-
const messageActionsHandler = (0,
|
|
53221
|
+
const userColor = (0, import_react209.useMemo)(() => getUserColor(theme, userId), [userId, theme]);
|
|
53222
|
+
const messageActionsHandler = (0, import_react209.useCallback)(
|
|
53215
53223
|
() => getMessageActions(["delete"], { canDelete: role.canDelete }),
|
|
53216
53224
|
[role]
|
|
53217
53225
|
);
|
|
53218
53226
|
const images = message?.attachments?.filter(({ type }) => type === "image");
|
|
53219
|
-
return /* @__PURE__ */
|
|
53227
|
+
return /* @__PURE__ */ import_react209.default.createElement(
|
|
53220
53228
|
"div",
|
|
53221
53229
|
{
|
|
53222
53230
|
className: `str-chat__virtual-message__wrapper ${role.isMyMessage ? "str-chat__virtual-message__wrapper--me" : ""} ${groupedByUser ? "str-chat__virtual-message__wrapper--group" : ""}`,
|
|
53223
53231
|
key: message.id
|
|
53224
53232
|
},
|
|
53225
|
-
message.user && /* @__PURE__ */
|
|
53233
|
+
message.user && /* @__PURE__ */ import_react209.default.createElement(
|
|
53226
53234
|
Avatar,
|
|
53227
53235
|
{
|
|
53228
53236
|
image: message.user.image,
|
|
@@ -53230,7 +53238,7 @@ var UnMemoizedFixedHeightMessage = (props) => {
|
|
|
53230
53238
|
user: message.user
|
|
53231
53239
|
}
|
|
53232
53240
|
),
|
|
53233
|
-
/* @__PURE__ */
|
|
53241
|
+
/* @__PURE__ */ import_react209.default.createElement("div", { className: "str-chat__virtual-message__content" }, /* @__PURE__ */ import_react209.default.createElement("div", { className: "str-chat__virtual-message__meta" }, /* @__PURE__ */ import_react209.default.createElement("div", { className: "str-chat__virtual-message__author", style: { color: userColor } }, /* @__PURE__ */ import_react209.default.createElement("strong", null, message.user?.name || "unknown"))), message.deleted_at || message.type === "deleted" ? /* @__PURE__ */ import_react209.default.createElement(MessageDeleted2, { message }) : /* @__PURE__ */ import_react209.default.createElement(import_react209.default.Fragment, null, images && /* @__PURE__ */ import_react209.default.createElement(Gallery, { images }), /* @__PURE__ */ import_react209.default.createElement("div", { className: "str-chat__virtual-message__text", "data-testid": "msg-text" }, renderedText, message.mml && /* @__PURE__ */ import_react209.default.createElement(MML, { actionHandler: handleAction, align: "left", source: message.mml }), /* @__PURE__ */ import_react209.default.createElement("div", { className: "str-chat__virtual-message__data" }, /* @__PURE__ */ import_react209.default.createElement(
|
|
53234
53242
|
MessageActions,
|
|
53235
53243
|
{
|
|
53236
53244
|
customWrapperClass: "str-chat__virtual-message__actions",
|
|
@@ -53239,7 +53247,7 @@ var UnMemoizedFixedHeightMessage = (props) => {
|
|
|
53239
53247
|
message,
|
|
53240
53248
|
mine: () => role.isMyMessage
|
|
53241
53249
|
}
|
|
53242
|
-
), /* @__PURE__ */
|
|
53250
|
+
), /* @__PURE__ */ import_react209.default.createElement("span", { className: "str-chat__virtual-message__date" }, /* @__PURE__ */ import_react209.default.createElement(
|
|
53243
53251
|
MessageTimestamp,
|
|
53244
53252
|
{
|
|
53245
53253
|
customClass: "str-chat__message-simple-timestamp",
|
|
@@ -53248,12 +53256,12 @@ var UnMemoizedFixedHeightMessage = (props) => {
|
|
|
53248
53256
|
))))))
|
|
53249
53257
|
);
|
|
53250
53258
|
};
|
|
53251
|
-
var FixedHeightMessage =
|
|
53259
|
+
var FixedHeightMessage = import_react209.default.memo(
|
|
53252
53260
|
UnMemoizedFixedHeightMessage
|
|
53253
53261
|
);
|
|
53254
53262
|
|
|
53255
53263
|
// src/components/Message/StreamedMessageText.tsx
|
|
53256
|
-
var
|
|
53264
|
+
var import_react210 = __toESM(require("react"));
|
|
53257
53265
|
var StreamedMessageText = (props) => {
|
|
53258
53266
|
const {
|
|
53259
53267
|
message: messageFromProps,
|
|
@@ -53269,7 +53277,7 @@ var StreamedMessageText = (props) => {
|
|
|
53269
53277
|
streamingLetterIntervalMs,
|
|
53270
53278
|
text: text7
|
|
53271
53279
|
});
|
|
53272
|
-
return /* @__PURE__ */
|
|
53280
|
+
return /* @__PURE__ */ import_react210.default.createElement(
|
|
53273
53281
|
MessageText,
|
|
53274
53282
|
{
|
|
53275
53283
|
message: { ...message, text: streamedMessageText },
|
|
@@ -53282,14 +53290,14 @@ var StreamedMessageText = (props) => {
|
|
|
53282
53290
|
var QuotedMessagePreviewHeader = () => {
|
|
53283
53291
|
const { setQuotedMessage } = useChannelActionContext("QuotedMessagePreview");
|
|
53284
53292
|
const { t: t2 } = useTranslationContext("QuotedMessagePreview");
|
|
53285
|
-
return /* @__PURE__ */
|
|
53293
|
+
return /* @__PURE__ */ import_react211.default.createElement("div", { className: "str-chat__quoted-message-preview-header" }, /* @__PURE__ */ import_react211.default.createElement("div", { className: "str-chat__quoted-message-reply-to-message" }, t2("Reply to Message")), /* @__PURE__ */ import_react211.default.createElement(
|
|
53286
53294
|
"button",
|
|
53287
53295
|
{
|
|
53288
53296
|
"aria-label": t2("aria/Cancel Reply"),
|
|
53289
53297
|
className: "str-chat__quoted-message-remove",
|
|
53290
53298
|
onClick: () => setQuotedMessage(void 0)
|
|
53291
53299
|
},
|
|
53292
|
-
/* @__PURE__ */
|
|
53300
|
+
/* @__PURE__ */ import_react211.default.createElement(CloseIcon, null)
|
|
53293
53301
|
));
|
|
53294
53302
|
};
|
|
53295
53303
|
var QuotedMessagePreview = ({
|
|
@@ -53300,23 +53308,23 @@ var QuotedMessagePreview = ({
|
|
|
53300
53308
|
const { Attachment: Attachment2 = Attachment, Avatar: Avatar2 = Avatar } = useComponentContext("QuotedMessagePreview");
|
|
53301
53309
|
const { userLanguage } = useTranslationContext("QuotedMessagePreview");
|
|
53302
53310
|
const quotedMessageText = quotedMessage.i18n?.[`${userLanguage}_text`] || quotedMessage.text;
|
|
53303
|
-
const renderedText = (0,
|
|
53311
|
+
const renderedText = (0, import_react211.useMemo)(
|
|
53304
53312
|
() => renderText2(quotedMessageText, quotedMessage.mentioned_users),
|
|
53305
53313
|
[quotedMessage.mentioned_users, quotedMessageText, renderText2]
|
|
53306
53314
|
);
|
|
53307
|
-
const quotedMessageAttachment = (0,
|
|
53315
|
+
const quotedMessageAttachment = (0, import_react211.useMemo)(() => {
|
|
53308
53316
|
const [attachment] = quotedMessage.attachments ?? [];
|
|
53309
53317
|
return attachment ? [attachment] : [];
|
|
53310
53318
|
}, [quotedMessage.attachments]);
|
|
53311
53319
|
if (!quotedMessageText && !quotedMessageAttachment) return null;
|
|
53312
53320
|
const poll = quotedMessage.poll_id && client.polls.fromState(quotedMessage.poll_id);
|
|
53313
|
-
return /* @__PURE__ */
|
|
53321
|
+
return /* @__PURE__ */ import_react211.default.createElement(
|
|
53314
53322
|
"div",
|
|
53315
53323
|
{
|
|
53316
53324
|
className: "str-chat__quoted-message-preview",
|
|
53317
53325
|
"data-testid": "quoted-message-preview"
|
|
53318
53326
|
},
|
|
53319
|
-
quotedMessage.user && /* @__PURE__ */
|
|
53327
|
+
quotedMessage.user && /* @__PURE__ */ import_react211.default.createElement(
|
|
53320
53328
|
Avatar2,
|
|
53321
53329
|
{
|
|
53322
53330
|
className: "str-chat__avatar--quoted-message-sender",
|
|
@@ -53325,7 +53333,7 @@ var QuotedMessagePreview = ({
|
|
|
53325
53333
|
user: quotedMessage.user
|
|
53326
53334
|
}
|
|
53327
53335
|
),
|
|
53328
|
-
/* @__PURE__ */
|
|
53336
|
+
/* @__PURE__ */ import_react211.default.createElement("div", { className: "str-chat__quoted-message-bubble" }, poll ? /* @__PURE__ */ import_react211.default.createElement(Poll, { isQuoted: true, poll }) : /* @__PURE__ */ import_react211.default.createElement(import_react211.default.Fragment, null, !!quotedMessageAttachment.length && /* @__PURE__ */ import_react211.default.createElement(Attachment2, { attachments: quotedMessageAttachment, isQuoted: true }), /* @__PURE__ */ import_react211.default.createElement(
|
|
53329
53337
|
"div",
|
|
53330
53338
|
{
|
|
53331
53339
|
className: "str-chat__quoted-message-text",
|
|
@@ -53338,20 +53346,20 @@ var QuotedMessagePreview = ({
|
|
|
53338
53346
|
|
|
53339
53347
|
// src/components/MessageInput/LinkPreviewList.tsx
|
|
53340
53348
|
var import_clsx54 = __toESM(require("clsx"));
|
|
53341
|
-
var
|
|
53349
|
+
var import_react212 = __toESM(require("react"));
|
|
53342
53350
|
var LinkPreviewList = ({ linkPreviews }) => {
|
|
53343
53351
|
const { quotedMessage } = useChannelStateContext();
|
|
53344
53352
|
const showLinkPreviews = linkPreviews.length > 0 && !quotedMessage;
|
|
53345
53353
|
if (!showLinkPreviews) return null;
|
|
53346
|
-
return /* @__PURE__ */
|
|
53347
|
-
(linkPreview) => linkPreview.state === "loaded" /* LOADED */ ? /* @__PURE__ */
|
|
53354
|
+
return /* @__PURE__ */ import_react212.default.createElement("div", { className: "str-chat__link-preview-list" }, Array.from(linkPreviews.values()).map(
|
|
53355
|
+
(linkPreview) => linkPreview.state === "loaded" /* LOADED */ ? /* @__PURE__ */ import_react212.default.createElement(LinkPreviewCard, { key: linkPreview.og_scrape_url, linkPreview }) : null
|
|
53348
53356
|
));
|
|
53349
53357
|
};
|
|
53350
53358
|
var LinkPreviewCard = ({ linkPreview }) => {
|
|
53351
53359
|
const { dismissLinkPreview } = useMessageInputContext();
|
|
53352
53360
|
const { handleEnter, handleLeave, tooltipVisible } = useEnterLeaveHandlers();
|
|
53353
|
-
const [referenceElement, setReferenceElement] = (0,
|
|
53354
|
-
return /* @__PURE__ */
|
|
53361
|
+
const [referenceElement, setReferenceElement] = (0, import_react212.useState)(null);
|
|
53362
|
+
return /* @__PURE__ */ import_react212.default.createElement(
|
|
53355
53363
|
"div",
|
|
53356
53364
|
{
|
|
53357
53365
|
className: (0, import_clsx54.default)("str-chat__link-preview-card", {
|
|
@@ -53359,7 +53367,7 @@ var LinkPreviewCard = ({ linkPreview }) => {
|
|
|
53359
53367
|
}),
|
|
53360
53368
|
"data-testid": "link-preview-card"
|
|
53361
53369
|
},
|
|
53362
|
-
/* @__PURE__ */
|
|
53370
|
+
/* @__PURE__ */ import_react212.default.createElement(
|
|
53363
53371
|
PopperTooltip,
|
|
53364
53372
|
{
|
|
53365
53373
|
offset: [0, 5],
|
|
@@ -53368,7 +53376,7 @@ var LinkPreviewCard = ({ linkPreview }) => {
|
|
|
53368
53376
|
},
|
|
53369
53377
|
linkPreview.og_scrape_url
|
|
53370
53378
|
),
|
|
53371
|
-
/* @__PURE__ */
|
|
53379
|
+
/* @__PURE__ */ import_react212.default.createElement(
|
|
53372
53380
|
"div",
|
|
53373
53381
|
{
|
|
53374
53382
|
className: "str-chat__link-preview-card__icon-container",
|
|
@@ -53376,23 +53384,23 @@ var LinkPreviewCard = ({ linkPreview }) => {
|
|
|
53376
53384
|
onMouseLeave: handleLeave,
|
|
53377
53385
|
ref: setReferenceElement
|
|
53378
53386
|
},
|
|
53379
|
-
/* @__PURE__ */
|
|
53387
|
+
/* @__PURE__ */ import_react212.default.createElement(LinkIcon, null)
|
|
53380
53388
|
),
|
|
53381
|
-
/* @__PURE__ */
|
|
53382
|
-
/* @__PURE__ */
|
|
53389
|
+
/* @__PURE__ */ import_react212.default.createElement("div", { className: "str-chat__link-preview-card__content" }, /* @__PURE__ */ import_react212.default.createElement("div", { className: "str-chat__link-preview-card__content-title" }, linkPreview.title), /* @__PURE__ */ import_react212.default.createElement("div", { className: "str-chat__link-preview-card__content-description" }, linkPreview.text)),
|
|
53390
|
+
/* @__PURE__ */ import_react212.default.createElement(
|
|
53383
53391
|
"button",
|
|
53384
53392
|
{
|
|
53385
53393
|
className: "str-chat__link-preview-card__dismiss-button",
|
|
53386
53394
|
"data-testid": "link-preview-card-dismiss-btn",
|
|
53387
53395
|
onClick: () => dismissLinkPreview(linkPreview)
|
|
53388
53396
|
},
|
|
53389
|
-
/* @__PURE__ */
|
|
53397
|
+
/* @__PURE__ */ import_react212.default.createElement(CloseIcon, null)
|
|
53390
53398
|
)
|
|
53391
53399
|
);
|
|
53392
53400
|
};
|
|
53393
53401
|
|
|
53394
53402
|
// src/components/ChatAutoComplete/ChatAutoComplete.tsx
|
|
53395
|
-
var
|
|
53403
|
+
var import_react213 = __toESM(require("react"));
|
|
53396
53404
|
var UnMemoizedChatAutoComplete = (props) => {
|
|
53397
53405
|
const {
|
|
53398
53406
|
AutocompleteSuggestionItem: SuggestionItem,
|
|
@@ -53414,7 +53422,7 @@ var UnMemoizedChatAutoComplete = (props) => {
|
|
|
53414
53422
|
const [firstSkin] = emoji.skins ?? [];
|
|
53415
53423
|
return emoji.native ?? firstSkin.native;
|
|
53416
53424
|
};
|
|
53417
|
-
const updateInnerRef = (0,
|
|
53425
|
+
const updateInnerRef = (0, import_react213.useCallback)(
|
|
53418
53426
|
(ref) => {
|
|
53419
53427
|
if (innerRef) {
|
|
53420
53428
|
innerRef.current = ref;
|
|
@@ -53422,7 +53430,7 @@ var UnMemoizedChatAutoComplete = (props) => {
|
|
|
53422
53430
|
},
|
|
53423
53431
|
[innerRef]
|
|
53424
53432
|
);
|
|
53425
|
-
return /* @__PURE__ */
|
|
53433
|
+
return /* @__PURE__ */ import_react213.default.createElement(
|
|
53426
53434
|
ReactTextareaAutocomplete,
|
|
53427
53435
|
{
|
|
53428
53436
|
additionalTextareaProps: messageInput.additionalTextareaProps,
|
|
@@ -53457,15 +53465,15 @@ var UnMemoizedChatAutoComplete = (props) => {
|
|
|
53457
53465
|
}
|
|
53458
53466
|
);
|
|
53459
53467
|
};
|
|
53460
|
-
var ChatAutoComplete =
|
|
53468
|
+
var ChatAutoComplete = import_react213.default.memo(
|
|
53461
53469
|
UnMemoizedChatAutoComplete
|
|
53462
53470
|
);
|
|
53463
53471
|
|
|
53464
53472
|
// src/components/AIStateIndicator/AIStateIndicator.tsx
|
|
53465
|
-
var
|
|
53473
|
+
var import_react215 = __toESM(require("react"));
|
|
53466
53474
|
|
|
53467
53475
|
// src/components/AIStateIndicator/hooks/useAIState.ts
|
|
53468
|
-
var
|
|
53476
|
+
var import_react214 = require("react");
|
|
53469
53477
|
var AIStates = {
|
|
53470
53478
|
Error: "AI_STATE_ERROR",
|
|
53471
53479
|
ExternalSources: "AI_STATE_EXTERNAL_SOURCES",
|
|
@@ -53474,8 +53482,8 @@ var AIStates = {
|
|
|
53474
53482
|
Thinking: "AI_STATE_THINKING"
|
|
53475
53483
|
};
|
|
53476
53484
|
var useAIState = (channel) => {
|
|
53477
|
-
const [aiState, setAiState] = (0,
|
|
53478
|
-
(0,
|
|
53485
|
+
const [aiState, setAiState] = (0, import_react214.useState)(AIStates.Idle);
|
|
53486
|
+
(0, import_react214.useEffect)(() => {
|
|
53479
53487
|
if (!channel) {
|
|
53480
53488
|
return;
|
|
53481
53489
|
}
|
|
@@ -53515,20 +53523,20 @@ var AIStateIndicator = ({
|
|
|
53515
53523
|
[AIStates.Thinking]: t2("Thinking..."),
|
|
53516
53524
|
[AIStates.Generating]: t2("Generating...")
|
|
53517
53525
|
};
|
|
53518
|
-
return aiState in allowedStates ? /* @__PURE__ */
|
|
53526
|
+
return aiState in allowedStates ? /* @__PURE__ */ import_react215.default.createElement("div", { className: "str-chat__ai-state-indicator-container" }, /* @__PURE__ */ import_react215.default.createElement("p", { className: "str-chat__ai-state-indicator-text" }, allowedStates[aiState])) : null;
|
|
53519
53527
|
};
|
|
53520
53528
|
|
|
53521
53529
|
// src/components/MessageInput/WithDragAndDropUpload.tsx
|
|
53522
|
-
var
|
|
53530
|
+
var import_react216 = __toESM(require("react"));
|
|
53523
53531
|
var import_react_dropzone2 = require("react-dropzone");
|
|
53524
53532
|
var import_clsx55 = __toESM(require("clsx"));
|
|
53525
|
-
var DragAndDropUploadContext =
|
|
53533
|
+
var DragAndDropUploadContext = import_react216.default.createContext({
|
|
53526
53534
|
subscribeToDrop: null
|
|
53527
53535
|
});
|
|
53528
|
-
var useDragAndDropUploadContext = () => (0,
|
|
53536
|
+
var useDragAndDropUploadContext = () => (0, import_react216.useContext)(DragAndDropUploadContext);
|
|
53529
53537
|
var useRegisterDropHandlers = ({ uploadNewFiles }) => {
|
|
53530
53538
|
const { subscribeToDrop } = useDragAndDropUploadContext();
|
|
53531
|
-
(0,
|
|
53539
|
+
(0, import_react216.useEffect)(() => {
|
|
53532
53540
|
const unsubscribe = subscribeToDrop?.(uploadNewFiles);
|
|
53533
53541
|
return unsubscribe;
|
|
53534
53542
|
}, [subscribeToDrop, uploadNewFiles]);
|
|
@@ -53539,26 +53547,26 @@ var WithDragAndDropUpload = ({
|
|
|
53539
53547
|
component: Component2 = "div",
|
|
53540
53548
|
style
|
|
53541
53549
|
}) => {
|
|
53542
|
-
const dropHandlersRef = (0,
|
|
53550
|
+
const dropHandlersRef = (0, import_react216.useRef)(/* @__PURE__ */ new Set());
|
|
53543
53551
|
const { acceptedFiles = [], multipleUploads } = useChannelStateContext();
|
|
53544
53552
|
const { t: t2 } = useTranslationContext();
|
|
53545
53553
|
const messageInputContext = useMessageInputContext();
|
|
53546
53554
|
const dragAndDropUploadContext = useDragAndDropUploadContext();
|
|
53547
53555
|
const isWithinMessageInputContext = typeof messageInputContext.uploadNewFiles === "function";
|
|
53548
|
-
const accept = (0,
|
|
53556
|
+
const accept = (0, import_react216.useMemo)(
|
|
53549
53557
|
() => acceptedFiles.reduce((mediaTypeMap, mediaType) => {
|
|
53550
53558
|
mediaTypeMap[mediaType] ?? (mediaTypeMap[mediaType] = []);
|
|
53551
53559
|
return mediaTypeMap;
|
|
53552
53560
|
}, {}),
|
|
53553
53561
|
[acceptedFiles]
|
|
53554
53562
|
);
|
|
53555
|
-
const subscribeToDrop = (0,
|
|
53563
|
+
const subscribeToDrop = (0, import_react216.useCallback)((fn) => {
|
|
53556
53564
|
dropHandlersRef.current.add(fn);
|
|
53557
53565
|
return () => {
|
|
53558
53566
|
dropHandlersRef.current.delete(fn);
|
|
53559
53567
|
};
|
|
53560
53568
|
}, []);
|
|
53561
|
-
const handleDrop = (0,
|
|
53569
|
+
const handleDrop = (0, import_react216.useCallback)((files) => {
|
|
53562
53570
|
dropHandlersRef.current.forEach((fn) => fn(files));
|
|
53563
53571
|
}, []);
|
|
53564
53572
|
const { getRootProps, isDragActive, isDragReject } = (0, import_react_dropzone2.useDropzone)({
|
|
@@ -53571,24 +53579,24 @@ var WithDragAndDropUpload = ({
|
|
|
53571
53579
|
onDrop: isWithinMessageInputContext ? messageInputContext.uploadNewFiles : handleDrop
|
|
53572
53580
|
});
|
|
53573
53581
|
if (dragAndDropUploadContext.subscribeToDrop !== null) {
|
|
53574
|
-
return /* @__PURE__ */
|
|
53582
|
+
return /* @__PURE__ */ import_react216.default.createElement(Component2, { className }, children);
|
|
53575
53583
|
}
|
|
53576
|
-
return /* @__PURE__ */
|
|
53584
|
+
return /* @__PURE__ */ import_react216.default.createElement(
|
|
53577
53585
|
DragAndDropUploadContext.Provider,
|
|
53578
53586
|
{
|
|
53579
53587
|
value: {
|
|
53580
53588
|
subscribeToDrop
|
|
53581
53589
|
}
|
|
53582
53590
|
},
|
|
53583
|
-
/* @__PURE__ */
|
|
53591
|
+
/* @__PURE__ */ import_react216.default.createElement(Component2, { ...getRootProps({ className, style }) }, isDragActive && /* @__PURE__ */ import_react216.default.createElement(
|
|
53584
53592
|
"div",
|
|
53585
53593
|
{
|
|
53586
53594
|
className: (0, import_clsx55.default)("str-chat__dropzone-container", {
|
|
53587
53595
|
"str-chat__dropzone-container--not-accepted": isDragReject
|
|
53588
53596
|
})
|
|
53589
53597
|
},
|
|
53590
|
-
!isDragReject && /* @__PURE__ */
|
|
53591
|
-
isDragReject && /* @__PURE__ */
|
|
53598
|
+
!isDragReject && /* @__PURE__ */ import_react216.default.createElement("p", null, t2("Drag your files here")),
|
|
53599
|
+
isDragReject && /* @__PURE__ */ import_react216.default.createElement("p", null, t2("Some of the files will not be accepted"))
|
|
53592
53600
|
), children)
|
|
53593
53601
|
);
|
|
53594
53602
|
};
|
|
@@ -53628,19 +53636,19 @@ var MessageInputFlat = () => {
|
|
|
53628
53636
|
const { setQuotedMessage } = useChannelActionContext("MessageInputFlat");
|
|
53629
53637
|
const { channel } = useChatContext("MessageInputFlat");
|
|
53630
53638
|
const { aiState } = useAIState(channel);
|
|
53631
|
-
const stopGenerating = (0,
|
|
53639
|
+
const stopGenerating = (0, import_react217.useCallback)(() => channel?.stopAIResponse(), [channel]);
|
|
53632
53640
|
const [
|
|
53633
53641
|
showRecordingPermissionDeniedNotification,
|
|
53634
53642
|
setShowRecordingPermissionDeniedNotification
|
|
53635
|
-
] = (0,
|
|
53636
|
-
const closePermissionDeniedNotification = (0,
|
|
53643
|
+
] = (0, import_react217.useState)(false);
|
|
53644
|
+
const closePermissionDeniedNotification = (0, import_react217.useCallback)(() => {
|
|
53637
53645
|
setShowRecordingPermissionDeniedNotification(false);
|
|
53638
53646
|
}, []);
|
|
53639
|
-
const failedUploadsCount = (0,
|
|
53647
|
+
const failedUploadsCount = (0, import_react217.useMemo)(
|
|
53640
53648
|
() => attachments.filter((a2) => a2.localMetadata?.uploadState === "failed").length,
|
|
53641
53649
|
[attachments]
|
|
53642
53650
|
);
|
|
53643
|
-
(0,
|
|
53651
|
+
(0, import_react217.useEffect)(() => {
|
|
53644
53652
|
const handleQuotedMessageUpdate = (e2) => {
|
|
53645
53653
|
if (e2.message?.id !== quotedMessage?.id) return;
|
|
53646
53654
|
if (e2.type === "message.deleted") {
|
|
@@ -53656,31 +53664,31 @@ var MessageInputFlat = () => {
|
|
|
53656
53664
|
channel?.off("message.updated", handleQuotedMessageUpdate);
|
|
53657
53665
|
};
|
|
53658
53666
|
}, [channel, quotedMessage]);
|
|
53659
|
-
if (recordingController.recordingState) return /* @__PURE__ */
|
|
53667
|
+
if (recordingController.recordingState) return /* @__PURE__ */ import_react217.default.createElement(AudioRecorder2, null);
|
|
53660
53668
|
const displayQuotedMessage = !message && quotedMessage && quotedMessage.parent_id === parent?.id;
|
|
53661
53669
|
const recordingEnabled = !!(recordingController.recorder && navigator.mediaDevices);
|
|
53662
53670
|
const isRecording = !!recordingController.recordingState;
|
|
53663
53671
|
const StopAIGenerationButton2 = StopAIGenerationButtonOverride === void 0 ? StopAIGenerationButton : StopAIGenerationButtonOverride;
|
|
53664
53672
|
const shouldDisplayStopAIGeneration = [AIStates.Thinking, AIStates.Generating].includes(aiState) && !!StopAIGenerationButton2;
|
|
53665
|
-
return /* @__PURE__ */
|
|
53673
|
+
return /* @__PURE__ */ import_react217.default.createElement(WithDragAndDropUpload, { className: "str-chat__message-input", component: "div" }, recordingEnabled && recordingController.permissionState === "denied" && showRecordingPermissionDeniedNotification && /* @__PURE__ */ import_react217.default.createElement(
|
|
53666
53674
|
RecordingPermissionDeniedNotification2,
|
|
53667
53675
|
{
|
|
53668
53676
|
onClose: closePermissionDeniedNotification,
|
|
53669
53677
|
permissionName: "microphone" /* MIC */
|
|
53670
53678
|
}
|
|
53671
|
-
), findAndEnqueueURLsToEnrich && /* @__PURE__ */
|
|
53679
|
+
), findAndEnqueueURLsToEnrich && /* @__PURE__ */ import_react217.default.createElement(LinkPreviewList2, { linkPreviews: Array.from(linkPreviews.values()) }), displayQuotedMessage && /* @__PURE__ */ import_react217.default.createElement(QuotedMessagePreviewHeader, null), /* @__PURE__ */ import_react217.default.createElement("div", { className: "str-chat__message-input-inner" }, /* @__PURE__ */ import_react217.default.createElement(AttachmentSelector2, null), /* @__PURE__ */ import_react217.default.createElement("div", { className: "str-chat__message-textarea-container" }, displayQuotedMessage && /* @__PURE__ */ import_react217.default.createElement(QuotedMessagePreview2, { quotedMessage }), isUploadEnabled && !!(numberOfUploads + failedUploadsCount || attachments.length > 0) && /* @__PURE__ */ import_react217.default.createElement(AttachmentPreviewList2, null), /* @__PURE__ */ import_react217.default.createElement("div", { className: "str-chat__message-textarea-with-emoji-picker" }, /* @__PURE__ */ import_react217.default.createElement(ChatAutoComplete, null), EmojiPicker && /* @__PURE__ */ import_react217.default.createElement(EmojiPicker, null))), shouldDisplayStopAIGeneration ? /* @__PURE__ */ import_react217.default.createElement(StopAIGenerationButton2, { onClick: stopGenerating }) : !hideSendButton && /* @__PURE__ */ import_react217.default.createElement(import_react217.default.Fragment, null, cooldownRemaining ? /* @__PURE__ */ import_react217.default.createElement(
|
|
53672
53680
|
CooldownTimer2,
|
|
53673
53681
|
{
|
|
53674
53682
|
cooldownInterval: cooldownRemaining,
|
|
53675
53683
|
setCooldownRemaining
|
|
53676
53684
|
}
|
|
53677
|
-
) : /* @__PURE__ */
|
|
53685
|
+
) : /* @__PURE__ */ import_react217.default.createElement(import_react217.default.Fragment, null, /* @__PURE__ */ import_react217.default.createElement(
|
|
53678
53686
|
SendButton2,
|
|
53679
53687
|
{
|
|
53680
53688
|
disabled: !numberOfUploads && !text7.length && attachments.length - failedUploadsCount === 0,
|
|
53681
53689
|
sendMessage: handleSubmit
|
|
53682
53690
|
}
|
|
53683
|
-
), recordingEnabled && /* @__PURE__ */
|
|
53691
|
+
), recordingEnabled && /* @__PURE__ */ import_react217.default.createElement(
|
|
53684
53692
|
StartRecordingAudioButton2,
|
|
53685
53693
|
{
|
|
53686
53694
|
disabled: isRecording || !asyncMessagesMultiSendEnabled && attachments.some(
|
|
@@ -53698,22 +53706,22 @@ var MessageInputFlat = () => {
|
|
|
53698
53706
|
var EditMessageForm = () => {
|
|
53699
53707
|
const { t: t2 } = useTranslationContext("EditMessageForm");
|
|
53700
53708
|
const { clearEditingState, handleSubmit } = useMessageInputContext("EditMessageForm");
|
|
53701
|
-
(0,
|
|
53709
|
+
(0, import_react218.useEffect)(() => {
|
|
53702
53710
|
const onKeyDown = (event) => {
|
|
53703
53711
|
if (event.key === "Escape") clearEditingState?.();
|
|
53704
53712
|
};
|
|
53705
53713
|
document.addEventListener("keydown", onKeyDown);
|
|
53706
53714
|
return () => document.removeEventListener("keydown", onKeyDown);
|
|
53707
53715
|
}, [clearEditingState]);
|
|
53708
|
-
return /* @__PURE__ */
|
|
53716
|
+
return /* @__PURE__ */ import_react218.default.createElement(
|
|
53709
53717
|
"form",
|
|
53710
53718
|
{
|
|
53711
53719
|
autoComplete: "off",
|
|
53712
53720
|
className: "str-chat__edit-message-form",
|
|
53713
53721
|
onSubmit: handleSubmit
|
|
53714
53722
|
},
|
|
53715
|
-
/* @__PURE__ */
|
|
53716
|
-
/* @__PURE__ */
|
|
53723
|
+
/* @__PURE__ */ import_react218.default.createElement(MessageInputFlat, null),
|
|
53724
|
+
/* @__PURE__ */ import_react218.default.createElement("div", { className: "str-chat__edit-message-form-options" }, /* @__PURE__ */ import_react218.default.createElement(
|
|
53717
53725
|
"button",
|
|
53718
53726
|
{
|
|
53719
53727
|
className: "str-chat__edit-message-cancel",
|
|
@@ -53721,7 +53729,7 @@ var EditMessageForm = () => {
|
|
|
53721
53729
|
onClick: clearEditingState
|
|
53722
53730
|
},
|
|
53723
53731
|
t2("Cancel")
|
|
53724
|
-
), /* @__PURE__ */
|
|
53732
|
+
), /* @__PURE__ */ import_react218.default.createElement(
|
|
53725
53733
|
"button",
|
|
53726
53734
|
{
|
|
53727
53735
|
className: "str-chat__edit-message-send",
|
|
@@ -53734,7 +53742,7 @@ var EditMessageForm = () => {
|
|
|
53734
53742
|
};
|
|
53735
53743
|
|
|
53736
53744
|
// src/components/MessageInput/MessageInput.tsx
|
|
53737
|
-
var
|
|
53745
|
+
var import_react219 = __toESM(require("react"));
|
|
53738
53746
|
var MessageInputProvider = (props) => {
|
|
53739
53747
|
const cooldownTimerState = useCooldownTimer();
|
|
53740
53748
|
const messageInputState = useMessageInputState(props);
|
|
@@ -53746,44 +53754,45 @@ var MessageInputProvider = (props) => {
|
|
|
53746
53754
|
emojiSearchIndex: props.emojiSearchIndex ?? emojiSearchIndex
|
|
53747
53755
|
});
|
|
53748
53756
|
useRegisterDropHandlers(messageInputContextValue);
|
|
53749
|
-
return /* @__PURE__ */
|
|
53757
|
+
return /* @__PURE__ */ import_react219.default.createElement(MessageInputContextProvider, { value: messageInputContextValue }, props.children);
|
|
53750
53758
|
};
|
|
53751
53759
|
var UnMemoizedMessageInput = (props) => {
|
|
53752
53760
|
const { Input: PropInput } = props;
|
|
53753
53761
|
const { dragAndDropWindow } = useChannelStateContext();
|
|
53754
53762
|
const { Input: ContextInput, TriggerProvider = DefaultTriggerProvider } = useComponentContext("MessageInput");
|
|
53763
|
+
const id = useStableId();
|
|
53755
53764
|
const Input = PropInput || ContextInput || MessageInputFlat;
|
|
53756
|
-
const dialogManagerId = props.isThreadInput ?
|
|
53765
|
+
const dialogManagerId = props.isThreadInput ? `message-input-dialog-manager-thread-${id}` : `message-input-dialog-manager-${id}`;
|
|
53757
53766
|
if (dragAndDropWindow)
|
|
53758
|
-
return /* @__PURE__ */
|
|
53759
|
-
return /* @__PURE__ */
|
|
53767
|
+
return /* @__PURE__ */ import_react219.default.createElement(DialogManagerProvider, { id: dialogManagerId }, /* @__PURE__ */ import_react219.default.createElement(TriggerProvider, null, /* @__PURE__ */ import_react219.default.createElement(Input, null)));
|
|
53768
|
+
return /* @__PURE__ */ import_react219.default.createElement(DialogManagerProvider, { id: dialogManagerId }, /* @__PURE__ */ import_react219.default.createElement(MessageInputProvider, { ...props }, /* @__PURE__ */ import_react219.default.createElement(TriggerProvider, null, /* @__PURE__ */ import_react219.default.createElement(Input, null))));
|
|
53760
53769
|
};
|
|
53761
|
-
var MessageInput =
|
|
53770
|
+
var MessageInput = import_react219.default.memo(
|
|
53762
53771
|
UnMemoizedMessageInput
|
|
53763
53772
|
);
|
|
53764
53773
|
|
|
53765
53774
|
// src/components/Reactions/ReactionsList.tsx
|
|
53766
|
-
var
|
|
53775
|
+
var import_react223 = __toESM(require("react"));
|
|
53767
53776
|
var import_clsx57 = __toESM(require("clsx"));
|
|
53768
53777
|
|
|
53769
53778
|
// src/components/Reactions/ReactionsListModal.tsx
|
|
53770
|
-
var
|
|
53779
|
+
var import_react221 = __toESM(require("react"));
|
|
53771
53780
|
var import_clsx56 = __toESM(require("clsx"));
|
|
53772
53781
|
|
|
53773
53782
|
// src/components/Reactions/hooks/useFetchReactions.ts
|
|
53774
|
-
var
|
|
53783
|
+
var import_react220 = require("react");
|
|
53775
53784
|
function useFetchReactions(options) {
|
|
53776
53785
|
const { handleFetchReactions: contextHandleFetchReactions } = useMessageContext("useFetchReactions");
|
|
53777
|
-
const [reactions, setReactions] = (0,
|
|
53786
|
+
const [reactions, setReactions] = (0, import_react220.useState)([]);
|
|
53778
53787
|
const {
|
|
53779
53788
|
handleFetchReactions: propHandleFetchReactions,
|
|
53780
53789
|
reactionType,
|
|
53781
53790
|
shouldFetch,
|
|
53782
53791
|
sort
|
|
53783
53792
|
} = options;
|
|
53784
|
-
const [isLoading, setIsLoading] = (0,
|
|
53793
|
+
const [isLoading, setIsLoading] = (0, import_react220.useState)(shouldFetch);
|
|
53785
53794
|
const handleFetchReactions = propHandleFetchReactions ?? contextHandleFetchReactions;
|
|
53786
|
-
(0,
|
|
53795
|
+
(0, import_react220.useEffect)(() => {
|
|
53787
53796
|
if (!shouldFetch) {
|
|
53788
53797
|
return;
|
|
53789
53798
|
}
|
|
@@ -53839,24 +53848,24 @@ function ReactionsListModal({
|
|
|
53839
53848
|
shouldFetch: modalProps.open,
|
|
53840
53849
|
sort: reactionDetailsSort
|
|
53841
53850
|
});
|
|
53842
|
-
const reactionDetailsWithLegacyFallback = (0,
|
|
53851
|
+
const reactionDetailsWithLegacyFallback = (0, import_react221.useMemo)(
|
|
53843
53852
|
() => legacySortReactionDetails ? [...reactionDetails].sort(legacySortReactionDetails) : reactionDetails,
|
|
53844
53853
|
[legacySortReactionDetails, reactionDetails]
|
|
53845
53854
|
);
|
|
53846
|
-
return /* @__PURE__ */
|
|
53855
|
+
return /* @__PURE__ */ import_react221.default.createElement(
|
|
53847
53856
|
Modal,
|
|
53848
53857
|
{
|
|
53849
53858
|
...modalProps,
|
|
53850
53859
|
className: (0, import_clsx56.default)("str-chat__message-reactions-details-modal", modalProps.className)
|
|
53851
53860
|
},
|
|
53852
|
-
/* @__PURE__ */
|
|
53861
|
+
/* @__PURE__ */ import_react221.default.createElement(
|
|
53853
53862
|
"div",
|
|
53854
53863
|
{
|
|
53855
53864
|
className: "str-chat__message-reactions-details",
|
|
53856
53865
|
"data-testid": "reactions-list-modal"
|
|
53857
53866
|
},
|
|
53858
|
-
/* @__PURE__ */
|
|
53859
|
-
({ EmojiComponent, reactionCount, reactionType }) => EmojiComponent && /* @__PURE__ */
|
|
53867
|
+
/* @__PURE__ */ import_react221.default.createElement("div", { className: "str-chat__message-reactions-details-reaction-types" }, reactions.map(
|
|
53868
|
+
({ EmojiComponent, reactionCount, reactionType }) => EmojiComponent && /* @__PURE__ */ import_react221.default.createElement(
|
|
53860
53869
|
"div",
|
|
53861
53870
|
{
|
|
53862
53871
|
className: (0, import_clsx56.default)("str-chat__message-reactions-details-reaction-type", {
|
|
@@ -53868,25 +53877,25 @@ function ReactionsListModal({
|
|
|
53868
53877
|
reactionType
|
|
53869
53878
|
)
|
|
53870
53879
|
},
|
|
53871
|
-
/* @__PURE__ */
|
|
53880
|
+
/* @__PURE__ */ import_react221.default.createElement("span", { className: "str-chat__message-reaction-emoji str-chat__message-reaction-emoji--with-fallback" }, /* @__PURE__ */ import_react221.default.createElement(EmojiComponent, null)),
|
|
53872
53881
|
"\xA0",
|
|
53873
|
-
/* @__PURE__ */
|
|
53882
|
+
/* @__PURE__ */ import_react221.default.createElement("span", { className: "str-chat__message-reaction-count" }, reactionCount)
|
|
53874
53883
|
)
|
|
53875
53884
|
)),
|
|
53876
|
-
SelectedEmojiComponent && /* @__PURE__ */
|
|
53877
|
-
/* @__PURE__ */
|
|
53885
|
+
SelectedEmojiComponent && /* @__PURE__ */ import_react221.default.createElement("div", { className: "str-chat__message-reaction-emoji str-chat__message-reaction-emoji--with-fallback str-chat__message-reaction-emoji-big" }, /* @__PURE__ */ import_react221.default.createElement(SelectedEmojiComponent, null)),
|
|
53886
|
+
/* @__PURE__ */ import_react221.default.createElement(
|
|
53878
53887
|
"div",
|
|
53879
53888
|
{
|
|
53880
53889
|
className: "str-chat__message-reactions-details-reacting-users",
|
|
53881
53890
|
"data-testid": "all-reacting-users"
|
|
53882
53891
|
},
|
|
53883
|
-
areReactionsLoading ? /* @__PURE__ */
|
|
53892
|
+
areReactionsLoading ? /* @__PURE__ */ import_react221.default.createElement(LoadingIndicator, null) : reactionDetailsWithLegacyFallback.map(({ user }) => /* @__PURE__ */ import_react221.default.createElement(
|
|
53884
53893
|
"div",
|
|
53885
53894
|
{
|
|
53886
53895
|
className: "str-chat__message-reactions-details-reacting-user",
|
|
53887
53896
|
key: user?.id
|
|
53888
53897
|
},
|
|
53889
|
-
/* @__PURE__ */
|
|
53898
|
+
/* @__PURE__ */ import_react221.default.createElement(
|
|
53890
53899
|
Avatar,
|
|
53891
53900
|
{
|
|
53892
53901
|
className: "stream-chat__avatar--reaction",
|
|
@@ -53895,7 +53904,7 @@ function ReactionsListModal({
|
|
|
53895
53904
|
name: user?.name || user?.id
|
|
53896
53905
|
}
|
|
53897
53906
|
),
|
|
53898
|
-
/* @__PURE__ */
|
|
53907
|
+
/* @__PURE__ */ import_react221.default.createElement(
|
|
53899
53908
|
"span",
|
|
53900
53909
|
{
|
|
53901
53910
|
className: "str-chat__user-item--name",
|
|
@@ -53910,7 +53919,7 @@ function ReactionsListModal({
|
|
|
53910
53919
|
}
|
|
53911
53920
|
|
|
53912
53921
|
// src/components/Reactions/hooks/useProcessReactions.tsx
|
|
53913
|
-
var
|
|
53922
|
+
var import_react222 = require("react");
|
|
53914
53923
|
var defaultReactionsSort = (a2, b) => {
|
|
53915
53924
|
if (a2.firstReactionAt && b.firstReactionAt) {
|
|
53916
53925
|
return +a2.firstReactionAt - +b.firstReactionAt;
|
|
@@ -53932,19 +53941,19 @@ var useProcessReactions = (params) => {
|
|
|
53932
53941
|
const latestReactions = propReactions || message.latest_reactions;
|
|
53933
53942
|
const ownReactions = propOwnReactions || message?.own_reactions;
|
|
53934
53943
|
const reactionGroups = propReactionGroups || message?.reaction_groups;
|
|
53935
|
-
const isOwnReaction = (0,
|
|
53944
|
+
const isOwnReaction = (0, import_react222.useCallback)(
|
|
53936
53945
|
(reactionType) => ownReactions?.some((reaction) => reaction.type === reactionType) ?? false,
|
|
53937
53946
|
[ownReactions]
|
|
53938
53947
|
);
|
|
53939
|
-
const getEmojiByReactionType = (0,
|
|
53948
|
+
const getEmojiByReactionType = (0, import_react222.useCallback)(
|
|
53940
53949
|
(reactionType) => reactionOptions.find(({ type }) => type === reactionType)?.Component ?? null,
|
|
53941
53950
|
[reactionOptions]
|
|
53942
53951
|
);
|
|
53943
|
-
const isSupportedReaction = (0,
|
|
53952
|
+
const isSupportedReaction = (0, import_react222.useCallback)(
|
|
53944
53953
|
(reactionType) => reactionOptions.some((reactionOption) => reactionOption.type === reactionType),
|
|
53945
53954
|
[reactionOptions]
|
|
53946
53955
|
);
|
|
53947
|
-
const getLatestReactedUserNames = (0,
|
|
53956
|
+
const getLatestReactedUserNames = (0, import_react222.useCallback)(
|
|
53948
53957
|
(reactionType) => latestReactions?.flatMap((reaction) => {
|
|
53949
53958
|
if (reactionType && reactionType === reaction.type) {
|
|
53950
53959
|
const username = reaction.user?.name || reaction.user?.id;
|
|
@@ -53954,7 +53963,7 @@ var useProcessReactions = (params) => {
|
|
|
53954
53963
|
}) ?? [],
|
|
53955
53964
|
[latestReactions]
|
|
53956
53965
|
);
|
|
53957
|
-
const existingReactions = (0,
|
|
53966
|
+
const existingReactions = (0, import_react222.useMemo)(() => {
|
|
53958
53967
|
if (!reactionGroups) {
|
|
53959
53968
|
return [];
|
|
53960
53969
|
}
|
|
@@ -53988,7 +53997,7 @@ var useProcessReactions = (params) => {
|
|
|
53988
53997
|
sortReactions
|
|
53989
53998
|
]);
|
|
53990
53999
|
const hasReactions = existingReactions.length > 0;
|
|
53991
|
-
const totalReactionCount = (0,
|
|
54000
|
+
const totalReactionCount = (0, import_react222.useMemo)(
|
|
53992
54001
|
() => existingReactions.reduce((total, { reactionCount }) => total + reactionCount, 0),
|
|
53993
54002
|
[existingReactions]
|
|
53994
54003
|
);
|
|
@@ -54010,7 +54019,7 @@ var UnMemoizedReactionsList = (props) => {
|
|
|
54010
54019
|
...rest
|
|
54011
54020
|
} = props;
|
|
54012
54021
|
const { existingReactions, hasReactions, totalReactionCount } = useProcessReactions(rest);
|
|
54013
|
-
const [selectedReactionType, setSelectedReactionType] = (0,
|
|
54022
|
+
const [selectedReactionType, setSelectedReactionType] = (0, import_react223.useState)(null);
|
|
54014
54023
|
const { t: t2 } = useTranslationContext("ReactionsList");
|
|
54015
54024
|
const { ReactionsListModal: ReactionsListModal2 = ReactionsListModal } = useComponentContext();
|
|
54016
54025
|
const handleReactionButtonClick = (reactionType) => {
|
|
@@ -54020,7 +54029,7 @@ var UnMemoizedReactionsList = (props) => {
|
|
|
54020
54029
|
setSelectedReactionType(reactionType);
|
|
54021
54030
|
};
|
|
54022
54031
|
if (!hasReactions) return null;
|
|
54023
|
-
return /* @__PURE__ */
|
|
54032
|
+
return /* @__PURE__ */ import_react223.default.createElement(import_react223.default.Fragment, null, /* @__PURE__ */ import_react223.default.createElement(
|
|
54024
54033
|
"div",
|
|
54025
54034
|
{
|
|
54026
54035
|
"aria-label": t2("aria/Reaction list"),
|
|
@@ -54031,8 +54040,8 @@ var UnMemoizedReactionsList = (props) => {
|
|
|
54031
54040
|
"data-testid": "reaction-list",
|
|
54032
54041
|
role: "figure"
|
|
54033
54042
|
},
|
|
54034
|
-
/* @__PURE__ */
|
|
54035
|
-
({ EmojiComponent, isOwnReaction, reactionCount, reactionType }) => EmojiComponent && /* @__PURE__ */
|
|
54043
|
+
/* @__PURE__ */ import_react223.default.createElement("ul", { className: "str-chat__message-reactions" }, existingReactions.map(
|
|
54044
|
+
({ EmojiComponent, isOwnReaction, reactionCount, reactionType }) => EmojiComponent && /* @__PURE__ */ import_react223.default.createElement(
|
|
54036
54045
|
"li",
|
|
54037
54046
|
{
|
|
54038
54047
|
className: (0, import_clsx57.default)("str-chat__message-reaction", {
|
|
@@ -54040,7 +54049,7 @@ var UnMemoizedReactionsList = (props) => {
|
|
|
54040
54049
|
}),
|
|
54041
54050
|
key: reactionType
|
|
54042
54051
|
},
|
|
54043
|
-
/* @__PURE__ */
|
|
54052
|
+
/* @__PURE__ */ import_react223.default.createElement(
|
|
54044
54053
|
"button",
|
|
54045
54054
|
{
|
|
54046
54055
|
"aria-label": `Reactions: ${reactionType}`,
|
|
@@ -54048,9 +54057,9 @@ var UnMemoizedReactionsList = (props) => {
|
|
|
54048
54057
|
onClick: () => handleReactionButtonClick(reactionType),
|
|
54049
54058
|
type: "button"
|
|
54050
54059
|
},
|
|
54051
|
-
/* @__PURE__ */
|
|
54060
|
+
/* @__PURE__ */ import_react223.default.createElement("span", { className: "str-chat__message-reaction-emoji" }, /* @__PURE__ */ import_react223.default.createElement(EmojiComponent, null)),
|
|
54052
54061
|
"\xA0",
|
|
54053
|
-
/* @__PURE__ */
|
|
54062
|
+
/* @__PURE__ */ import_react223.default.createElement(
|
|
54054
54063
|
"span",
|
|
54055
54064
|
{
|
|
54056
54065
|
className: "str-chat__message-reaction-count",
|
|
@@ -54060,8 +54069,8 @@ var UnMemoizedReactionsList = (props) => {
|
|
|
54060
54069
|
)
|
|
54061
54070
|
)
|
|
54062
54071
|
)
|
|
54063
|
-
), /* @__PURE__ */
|
|
54064
|
-
), selectedReactionType !== null && /* @__PURE__ */
|
|
54072
|
+
), /* @__PURE__ */ import_react223.default.createElement("li", null, /* @__PURE__ */ import_react223.default.createElement("span", { className: "str-chat__reaction-list--counter" }, totalReactionCount)))
|
|
54073
|
+
), selectedReactionType !== null && /* @__PURE__ */ import_react223.default.createElement(
|
|
54065
54074
|
ReactionsListModal2,
|
|
54066
54075
|
{
|
|
54067
54076
|
handleFetchReactions,
|
|
@@ -54074,12 +54083,12 @@ var UnMemoizedReactionsList = (props) => {
|
|
|
54074
54083
|
}
|
|
54075
54084
|
));
|
|
54076
54085
|
};
|
|
54077
|
-
var ReactionsList =
|
|
54086
|
+
var ReactionsList = import_react223.default.memo(
|
|
54078
54087
|
UnMemoizedReactionsList
|
|
54079
54088
|
);
|
|
54080
54089
|
|
|
54081
54090
|
// src/components/Reactions/SimpleReactionsList.tsx
|
|
54082
|
-
var
|
|
54091
|
+
var import_react224 = __toESM(require("react"));
|
|
54083
54092
|
var import_clsx58 = __toESM(require("clsx"));
|
|
54084
54093
|
var WithTooltip = ({
|
|
54085
54094
|
children,
|
|
@@ -54087,12 +54096,12 @@ var WithTooltip = ({
|
|
|
54087
54096
|
onMouseLeave,
|
|
54088
54097
|
title
|
|
54089
54098
|
}) => {
|
|
54090
|
-
const [referenceElement, setReferenceElement] = (0,
|
|
54099
|
+
const [referenceElement, setReferenceElement] = (0, import_react224.useState)(null);
|
|
54091
54100
|
const { handleEnter, handleLeave, tooltipVisible } = useEnterLeaveHandlers({
|
|
54092
54101
|
onMouseEnter,
|
|
54093
54102
|
onMouseLeave
|
|
54094
54103
|
});
|
|
54095
|
-
return /* @__PURE__ */
|
|
54104
|
+
return /* @__PURE__ */ import_react224.default.createElement(import_react224.default.Fragment, null, /* @__PURE__ */ import_react224.default.createElement(PopperTooltip, { referenceElement, visible: tooltipVisible }, title), /* @__PURE__ */ import_react224.default.createElement(
|
|
54096
54105
|
"span",
|
|
54097
54106
|
{
|
|
54098
54107
|
onMouseEnter: handleEnter,
|
|
@@ -54108,7 +54117,7 @@ var UnMemoizedSimpleReactionsList = (props) => {
|
|
|
54108
54117
|
const { existingReactions, hasReactions, totalReactionCount } = useProcessReactions(rest);
|
|
54109
54118
|
const handleReaction = propHandleReaction || contextHandleReaction;
|
|
54110
54119
|
if (!hasReactions) return null;
|
|
54111
|
-
return /* @__PURE__ */
|
|
54120
|
+
return /* @__PURE__ */ import_react224.default.createElement("div", { className: "str-chat__message-reactions-container" }, /* @__PURE__ */ import_react224.default.createElement(
|
|
54112
54121
|
"ul",
|
|
54113
54122
|
{
|
|
54114
54123
|
className: "str-chat__simple-reactions-list str-chat__message-reactions",
|
|
@@ -54117,7 +54126,7 @@ var UnMemoizedSimpleReactionsList = (props) => {
|
|
|
54117
54126
|
existingReactions.map(
|
|
54118
54127
|
({ EmojiComponent, isOwnReaction, latestReactedUserNames, reactionType }) => {
|
|
54119
54128
|
const tooltipContent = latestReactedUserNames.join(", ");
|
|
54120
|
-
return EmojiComponent && /* @__PURE__ */
|
|
54129
|
+
return EmojiComponent && /* @__PURE__ */ import_react224.default.createElement(
|
|
54121
54130
|
"li",
|
|
54122
54131
|
{
|
|
54123
54132
|
className: (0, import_clsx58.default)("str-chat__simple-reactions-list-item", {
|
|
@@ -54127,19 +54136,19 @@ var UnMemoizedSimpleReactionsList = (props) => {
|
|
|
54127
54136
|
onClick: (event) => handleReaction(reactionType, event),
|
|
54128
54137
|
onKeyUp: (event) => handleReaction(reactionType, event)
|
|
54129
54138
|
},
|
|
54130
|
-
/* @__PURE__ */
|
|
54139
|
+
/* @__PURE__ */ import_react224.default.createElement(WithTooltip, { title: tooltipContent }, /* @__PURE__ */ import_react224.default.createElement(EmojiComponent, null))
|
|
54131
54140
|
);
|
|
54132
54141
|
}
|
|
54133
54142
|
),
|
|
54134
|
-
/* @__PURE__ */
|
|
54143
|
+
/* @__PURE__ */ import_react224.default.createElement("li", { className: "str-chat__simple-reactions-list-item--last-number" }, totalReactionCount)
|
|
54135
54144
|
));
|
|
54136
54145
|
};
|
|
54137
|
-
var SimpleReactionsList =
|
|
54146
|
+
var SimpleReactionsList = import_react224.default.memo(
|
|
54138
54147
|
UnMemoizedSimpleReactionsList
|
|
54139
54148
|
);
|
|
54140
54149
|
|
|
54141
54150
|
// src/components/Message/MessageEditedTimestamp.tsx
|
|
54142
|
-
var
|
|
54151
|
+
var import_react225 = __toESM(require("react"));
|
|
54143
54152
|
var import_clsx59 = __toESM(require("clsx"));
|
|
54144
54153
|
function MessageEditedTimestamp({
|
|
54145
54154
|
message: propMessage,
|
|
@@ -54155,7 +54164,7 @@ function MessageEditedTimestamp({
|
|
|
54155
54164
|
if (!isMessageEdited(message)) {
|
|
54156
54165
|
return null;
|
|
54157
54166
|
}
|
|
54158
|
-
return /* @__PURE__ */
|
|
54167
|
+
return /* @__PURE__ */ import_react225.default.createElement(
|
|
54159
54168
|
"div",
|
|
54160
54169
|
{
|
|
54161
54170
|
className: (0, import_clsx59.default)(
|
|
@@ -54166,7 +54175,7 @@ function MessageEditedTimestamp({
|
|
|
54166
54175
|
},
|
|
54167
54176
|
t2("Edited"),
|
|
54168
54177
|
" ",
|
|
54169
|
-
/* @__PURE__ */
|
|
54178
|
+
/* @__PURE__ */ import_react225.default.createElement(Timestamp2, { timestamp: message.message_text_updated_at, ...timestampProps })
|
|
54170
54179
|
);
|
|
54171
54180
|
}
|
|
54172
54181
|
|
|
@@ -54193,8 +54202,8 @@ var MessageSimpleWithContext = (props) => {
|
|
|
54193
54202
|
} = props;
|
|
54194
54203
|
const { client } = useChatContext("MessageSimple");
|
|
54195
54204
|
const { t: t2 } = useTranslationContext("MessageSimple");
|
|
54196
|
-
const [isBounceDialogOpen, setIsBounceDialogOpen] = (0,
|
|
54197
|
-
const [isEditedTimestampOpen, setEditedTimestampOpen] = (0,
|
|
54205
|
+
const [isBounceDialogOpen, setIsBounceDialogOpen] = (0, import_react226.useState)(false);
|
|
54206
|
+
const [isEditedTimestampOpen, setEditedTimestampOpen] = (0, import_react226.useState)(false);
|
|
54198
54207
|
const {
|
|
54199
54208
|
Attachment: Attachment2 = Attachment,
|
|
54200
54209
|
Avatar: Avatar2 = Avatar,
|
|
@@ -54215,7 +54224,7 @@ var MessageSimpleWithContext = (props) => {
|
|
|
54215
54224
|
} = useComponentContext("MessageSimple");
|
|
54216
54225
|
const hasAttachment = messageHasAttachments(message);
|
|
54217
54226
|
const hasReactions = messageHasReactions(message);
|
|
54218
|
-
const isAIGenerated = (0,
|
|
54227
|
+
const isAIGenerated = (0, import_react226.useMemo)(
|
|
54219
54228
|
() => isMessageAIGenerated?.(message),
|
|
54220
54229
|
[isMessageAIGenerated, message]
|
|
54221
54230
|
);
|
|
@@ -54223,10 +54232,10 @@ var MessageSimpleWithContext = (props) => {
|
|
|
54223
54232
|
return null;
|
|
54224
54233
|
}
|
|
54225
54234
|
if (message.deleted_at || message.type === "deleted") {
|
|
54226
|
-
return /* @__PURE__ */
|
|
54235
|
+
return /* @__PURE__ */ import_react226.default.createElement(MessageDeleted2, { message });
|
|
54227
54236
|
}
|
|
54228
54237
|
if (isMessageBlocked(message)) {
|
|
54229
|
-
return /* @__PURE__ */
|
|
54238
|
+
return /* @__PURE__ */ import_react226.default.createElement(MessageBlocked2, null);
|
|
54230
54239
|
}
|
|
54231
54240
|
const showMetadata = !groupedByUser || endOfGroup;
|
|
54232
54241
|
const showReplyCountButton = !threadList && !!message.reply_count;
|
|
@@ -54260,14 +54269,14 @@ var MessageSimpleWithContext = (props) => {
|
|
|
54260
54269
|
}
|
|
54261
54270
|
);
|
|
54262
54271
|
const poll = message.poll_id && client.polls.fromState(message.poll_id);
|
|
54263
|
-
return /* @__PURE__ */
|
|
54272
|
+
return /* @__PURE__ */ import_react226.default.createElement(import_react226.default.Fragment, null, editing && /* @__PURE__ */ import_react226.default.createElement(
|
|
54264
54273
|
Modal,
|
|
54265
54274
|
{
|
|
54266
54275
|
className: "str-chat__edit-message-modal",
|
|
54267
54276
|
onClose: clearEditingState,
|
|
54268
54277
|
open: editing
|
|
54269
54278
|
},
|
|
54270
|
-
/* @__PURE__ */
|
|
54279
|
+
/* @__PURE__ */ import_react226.default.createElement(
|
|
54271
54280
|
MessageInput,
|
|
54272
54281
|
{
|
|
54273
54282
|
clearEditingState,
|
|
@@ -54278,14 +54287,14 @@ var MessageSimpleWithContext = (props) => {
|
|
|
54278
54287
|
...additionalMessageInputProps
|
|
54279
54288
|
}
|
|
54280
54289
|
)
|
|
54281
|
-
), isBounceDialogOpen && /* @__PURE__ */
|
|
54290
|
+
), isBounceDialogOpen && /* @__PURE__ */ import_react226.default.createElement(
|
|
54282
54291
|
MessageBounceModal,
|
|
54283
54292
|
{
|
|
54284
54293
|
MessageBouncePrompt: MessageBouncePrompt2,
|
|
54285
54294
|
onClose: () => setIsBounceDialogOpen(false),
|
|
54286
54295
|
open: isBounceDialogOpen
|
|
54287
54296
|
}
|
|
54288
|
-
), /* @__PURE__ */
|
|
54297
|
+
), /* @__PURE__ */ import_react226.default.createElement("div", { className: rootClassName2, key: message.id }, PinIndicator2 && /* @__PURE__ */ import_react226.default.createElement(PinIndicator2, null), message.user && /* @__PURE__ */ import_react226.default.createElement(
|
|
54289
54298
|
Avatar2,
|
|
54290
54299
|
{
|
|
54291
54300
|
image: message.user.image,
|
|
@@ -54294,7 +54303,7 @@ var MessageSimpleWithContext = (props) => {
|
|
|
54294
54303
|
onMouseOver: onUserHover,
|
|
54295
54304
|
user: message.user
|
|
54296
54305
|
}
|
|
54297
|
-
), /* @__PURE__ */
|
|
54306
|
+
), /* @__PURE__ */ import_react226.default.createElement(
|
|
54298
54307
|
"div",
|
|
54299
54308
|
{
|
|
54300
54309
|
className: (0, import_clsx60.default)("str-chat__message-inner", {
|
|
@@ -54304,37 +54313,37 @@ var MessageSimpleWithContext = (props) => {
|
|
|
54304
54313
|
onClick: handleClick,
|
|
54305
54314
|
onKeyUp: handleClick
|
|
54306
54315
|
},
|
|
54307
|
-
/* @__PURE__ */
|
|
54308
|
-
/* @__PURE__ */
|
|
54309
|
-
/* @__PURE__ */
|
|
54316
|
+
/* @__PURE__ */ import_react226.default.createElement(MessageActions2, null),
|
|
54317
|
+
/* @__PURE__ */ import_react226.default.createElement("div", { className: "str-chat__message-reactions-host" }, hasReactions && /* @__PURE__ */ import_react226.default.createElement(ReactionsList2, { reverse: true })),
|
|
54318
|
+
/* @__PURE__ */ import_react226.default.createElement("div", { className: "str-chat__message-bubble" }, poll && /* @__PURE__ */ import_react226.default.createElement(Poll, { poll }), message.attachments?.length && !message.quoted_message ? /* @__PURE__ */ import_react226.default.createElement(
|
|
54310
54319
|
Attachment2,
|
|
54311
54320
|
{
|
|
54312
54321
|
actionHandler: handleAction,
|
|
54313
54322
|
attachments: message.attachments
|
|
54314
54323
|
}
|
|
54315
|
-
) : null, isAIGenerated ? /* @__PURE__ */
|
|
54324
|
+
) : null, isAIGenerated ? /* @__PURE__ */ import_react226.default.createElement(StreamedMessageText2, { message, renderText: renderText2 }) : /* @__PURE__ */ import_react226.default.createElement(MessageText, { message, renderText: renderText2 }), message.mml && /* @__PURE__ */ import_react226.default.createElement(
|
|
54316
54325
|
MML,
|
|
54317
54326
|
{
|
|
54318
54327
|
actionHandler: handleAction,
|
|
54319
54328
|
align: isMyMessage() ? "right" : "left",
|
|
54320
54329
|
source: message.mml
|
|
54321
54330
|
}
|
|
54322
|
-
), /* @__PURE__ */
|
|
54323
|
-
), showReplyCountButton && /* @__PURE__ */
|
|
54331
|
+
), /* @__PURE__ */ import_react226.default.createElement(MessageErrorIcon, null))
|
|
54332
|
+
), showReplyCountButton && /* @__PURE__ */ import_react226.default.createElement(
|
|
54324
54333
|
MessageRepliesCountButton2,
|
|
54325
54334
|
{
|
|
54326
54335
|
onClick: handleOpenThread,
|
|
54327
54336
|
reply_count: message.reply_count
|
|
54328
54337
|
}
|
|
54329
|
-
), showMetadata && /* @__PURE__ */
|
|
54338
|
+
), showMetadata && /* @__PURE__ */ import_react226.default.createElement("div", { className: "str-chat__message-metadata" }, /* @__PURE__ */ import_react226.default.createElement(MessageStatus2, null), !isMyMessage() && !!message.user && /* @__PURE__ */ import_react226.default.createElement("span", { className: "str-chat__message-simple-name" }, message.user.name || message.user.id), /* @__PURE__ */ import_react226.default.createElement(MessageTimestamp2, { customClass: "str-chat__message-simple-timestamp" }), isEdited && /* @__PURE__ */ import_react226.default.createElement("span", { className: "str-chat__mesage-simple-edited" }, t2("Edited")), isEdited && /* @__PURE__ */ import_react226.default.createElement(MessageEditedTimestamp, { calendar: true, open: isEditedTimestampOpen }))));
|
|
54330
54339
|
};
|
|
54331
|
-
var MemoizedMessageSimple =
|
|
54340
|
+
var MemoizedMessageSimple = import_react226.default.memo(
|
|
54332
54341
|
MessageSimpleWithContext,
|
|
54333
54342
|
areMessageUIPropsEqual
|
|
54334
54343
|
);
|
|
54335
54344
|
var MessageSimple = (props) => {
|
|
54336
54345
|
const messageContext = useMessageContext("MessageSimple");
|
|
54337
|
-
return /* @__PURE__ */
|
|
54346
|
+
return /* @__PURE__ */ import_react226.default.createElement(MemoizedMessageSimple, { ...messageContext, ...props });
|
|
54338
54347
|
};
|
|
54339
54348
|
|
|
54340
54349
|
// src/components/Message/Message.tsx
|
|
@@ -54370,11 +54379,11 @@ var MessageWithContext = (props) => {
|
|
|
54370
54379
|
canReply,
|
|
54371
54380
|
isMyMessage
|
|
54372
54381
|
} = userRoles;
|
|
54373
|
-
const messageIsUnread = (0,
|
|
54382
|
+
const messageIsUnread = (0, import_react227.useMemo)(
|
|
54374
54383
|
() => !!(!isMyMessage && client.user?.id && read && (!read[client.user.id] || message?.created_at && new Date(message.created_at).getTime() > read[client.user.id].last_read.getTime())),
|
|
54375
54384
|
[client, isMyMessage, message.created_at, read]
|
|
54376
54385
|
);
|
|
54377
|
-
const messageActionsHandler = (0,
|
|
54386
|
+
const messageActionsHandler = (0, import_react227.useCallback)(
|
|
54378
54387
|
() => getMessageActions(messageActions, {
|
|
54379
54388
|
canDelete,
|
|
54380
54389
|
canEdit,
|
|
@@ -54428,9 +54437,9 @@ var MessageWithContext = (props) => {
|
|
|
54428
54437
|
onUserHover,
|
|
54429
54438
|
setEditingState: setEdit
|
|
54430
54439
|
};
|
|
54431
|
-
return /* @__PURE__ */
|
|
54440
|
+
return /* @__PURE__ */ import_react227.default.createElement(MessageProvider, { value: messageContextValue }, /* @__PURE__ */ import_react227.default.createElement(MessageUIComponent, { groupedByUser }));
|
|
54432
54441
|
};
|
|
54433
|
-
var MemoizedMessage =
|
|
54442
|
+
var MemoizedMessage = import_react227.default.memo(
|
|
54434
54443
|
MessageWithContext,
|
|
54435
54444
|
areMessagePropsEqual
|
|
54436
54445
|
);
|
|
@@ -54497,7 +54506,7 @@ var Message = (props) => {
|
|
|
54497
54506
|
notify: addNotification
|
|
54498
54507
|
});
|
|
54499
54508
|
const highlighted = highlightedMessageId === message.id;
|
|
54500
|
-
return /* @__PURE__ */
|
|
54509
|
+
return /* @__PURE__ */ import_react227.default.createElement(
|
|
54501
54510
|
MemoizedMessage,
|
|
54502
54511
|
{
|
|
54503
54512
|
additionalMessageInputProps: props.additionalMessageInputProps,
|
|
@@ -54549,18 +54558,18 @@ var Message = (props) => {
|
|
|
54549
54558
|
// src/components/MessageList/GiphyPreviewMessage.tsx
|
|
54550
54559
|
var GiphyPreviewMessage = (props) => {
|
|
54551
54560
|
const { message } = props;
|
|
54552
|
-
return /* @__PURE__ */
|
|
54561
|
+
return /* @__PURE__ */ import_react228.default.createElement("div", { className: "giphy-preview-message" }, /* @__PURE__ */ import_react228.default.createElement(Message, { message }));
|
|
54553
54562
|
};
|
|
54554
54563
|
|
|
54555
54564
|
// src/components/MessageList/MessageList.tsx
|
|
54556
54565
|
var import_clsx62 = __toESM(require("clsx"));
|
|
54557
|
-
var
|
|
54566
|
+
var import_react247 = __toESM(require("react"));
|
|
54558
54567
|
|
|
54559
54568
|
// src/components/MessageList/hooks/MessageList/useEnrichedMessages.ts
|
|
54560
|
-
var
|
|
54569
|
+
var import_react229 = require("react");
|
|
54561
54570
|
|
|
54562
54571
|
// src/components/MessageList/utils.ts
|
|
54563
|
-
var
|
|
54572
|
+
var import_nanoid10 = require("nanoid");
|
|
54564
54573
|
var processMessages = (params) => {
|
|
54565
54574
|
const { messages, reviewProcessedMessage, setGiphyPreviewMessage, ...context } = params;
|
|
54566
54575
|
const {
|
|
@@ -54636,9 +54645,9 @@ var processMessages = (params) => {
|
|
|
54636
54645
|
var makeDateMessageId = (date) => {
|
|
54637
54646
|
let idSuffix;
|
|
54638
54647
|
try {
|
|
54639
|
-
idSuffix = !date ? (0,
|
|
54648
|
+
idSuffix = !date ? (0, import_nanoid10.nanoid)() : date instanceof Date ? date.toISOString() : date;
|
|
54640
54649
|
} catch (e2) {
|
|
54641
|
-
idSuffix = (0,
|
|
54650
|
+
idSuffix = (0, import_nanoid10.nanoid)();
|
|
54642
54651
|
}
|
|
54643
54652
|
return `${CUSTOM_MESSAGE_TYPE.date}-${idSuffix}`;
|
|
54644
54653
|
};
|
|
@@ -54764,7 +54773,7 @@ var useEnrichedMessages = (args) => {
|
|
|
54764
54773
|
} = args;
|
|
54765
54774
|
const { client } = useChatContext("useEnrichedMessages");
|
|
54766
54775
|
const { HeaderComponent } = useComponentContext("useEnrichedMessages");
|
|
54767
|
-
const lastRead = (0,
|
|
54776
|
+
const lastRead = (0, import_react229.useMemo)(() => channel.lastRead?.(), [channel]);
|
|
54768
54777
|
const enableDateSeparator = !disableDateSeparator;
|
|
54769
54778
|
let messagesWithDates = !enableDateSeparator && !hideDeletedMessages && hideNewMessageSeparator ? messages : processMessages({
|
|
54770
54779
|
enableDateSeparator,
|
|
@@ -54779,7 +54788,7 @@ var useEnrichedMessages = (args) => {
|
|
|
54779
54788
|
messagesWithDates = insertIntro(messagesWithDates, headerPosition);
|
|
54780
54789
|
}
|
|
54781
54790
|
const groupStylesFn = groupStyles || getGroupStyles;
|
|
54782
|
-
const messageGroupStyles = (0,
|
|
54791
|
+
const messageGroupStyles = (0, import_react229.useMemo)(
|
|
54783
54792
|
() => messagesWithDates.reduce((acc, message, i) => {
|
|
54784
54793
|
const style = groupStylesFn(
|
|
54785
54794
|
message,
|
|
@@ -54798,13 +54807,13 @@ var useEnrichedMessages = (args) => {
|
|
|
54798
54807
|
};
|
|
54799
54808
|
|
|
54800
54809
|
// src/components/MessageList/hooks/MessageList/useMessageListElements.tsx
|
|
54801
|
-
var
|
|
54810
|
+
var import_react231 = require("react");
|
|
54802
54811
|
|
|
54803
54812
|
// src/components/MessageList/hooks/useLastReadData.ts
|
|
54804
|
-
var
|
|
54813
|
+
var import_react230 = require("react");
|
|
54805
54814
|
var useLastReadData = (props) => {
|
|
54806
54815
|
const { messages, read, returnAllReadData, userID } = props;
|
|
54807
|
-
return (0,
|
|
54816
|
+
return (0, import_react230.useMemo)(
|
|
54808
54817
|
() => getReadStates(
|
|
54809
54818
|
messages.filter(({ user }) => user?.id === userID),
|
|
54810
54819
|
read,
|
|
@@ -54836,11 +54845,11 @@ var useMessageListElements = (props) => {
|
|
|
54836
54845
|
returnAllReadData,
|
|
54837
54846
|
userID: client.userID
|
|
54838
54847
|
});
|
|
54839
|
-
const lastReceivedMessageId = (0,
|
|
54848
|
+
const lastReceivedMessageId = (0, import_react231.useMemo)(
|
|
54840
54849
|
() => getLastReceived(enrichedMessages),
|
|
54841
54850
|
[enrichedMessages]
|
|
54842
54851
|
);
|
|
54843
|
-
const elements = (0,
|
|
54852
|
+
const elements = (0, import_react231.useMemo)(
|
|
54844
54853
|
() => renderMessages({
|
|
54845
54854
|
channelUnreadUiState,
|
|
54846
54855
|
components,
|
|
@@ -54867,7 +54876,7 @@ var useMessageListElements = (props) => {
|
|
|
54867
54876
|
};
|
|
54868
54877
|
|
|
54869
54878
|
// src/components/MessageList/hooks/MessageList/useMessageListScrollManager.ts
|
|
54870
|
-
var
|
|
54879
|
+
var import_react232 = require("react");
|
|
54871
54880
|
function useMessageListScrollManager(params) {
|
|
54872
54881
|
const {
|
|
54873
54882
|
loadMoreScrollThreshold,
|
|
@@ -54878,13 +54887,13 @@ function useMessageListScrollManager(params) {
|
|
|
54878
54887
|
showNewMessages
|
|
54879
54888
|
} = params;
|
|
54880
54889
|
const { client } = useChatContext("useMessageListScrollManager");
|
|
54881
|
-
const measures = (0,
|
|
54890
|
+
const measures = (0, import_react232.useRef)({
|
|
54882
54891
|
offsetHeight: 0,
|
|
54883
54892
|
scrollHeight: 0
|
|
54884
54893
|
});
|
|
54885
|
-
const messages = (0,
|
|
54886
|
-
const scrollTop = (0,
|
|
54887
|
-
(0,
|
|
54894
|
+
const messages = (0, import_react232.useRef)(void 0);
|
|
54895
|
+
const scrollTop = (0, import_react232.useRef)(0);
|
|
54896
|
+
(0, import_react232.useLayoutEffect)(() => {
|
|
54888
54897
|
const prevMeasures = measures.current;
|
|
54889
54898
|
const prevMessages = messages.current;
|
|
54890
54899
|
const newMessages = params.messages;
|
|
@@ -54924,7 +54933,7 @@ function useMessageListScrollManager(params) {
|
|
|
54924
54933
|
}
|
|
54925
54934
|
|
|
54926
54935
|
// src/components/MessageList/hooks/MessageList/useScrollLocationLogic.tsx
|
|
54927
|
-
var
|
|
54936
|
+
var import_react233 = require("react");
|
|
54928
54937
|
var useScrollLocationLogic = (params) => {
|
|
54929
54938
|
const {
|
|
54930
54939
|
hasMoreNewer,
|
|
@@ -54934,12 +54943,12 @@ var useScrollLocationLogic = (params) => {
|
|
|
54934
54943
|
scrolledUpThreshold = 200,
|
|
54935
54944
|
suppressAutoscroll
|
|
54936
54945
|
} = params;
|
|
54937
|
-
const [hasNewMessages, setHasNewMessages] = (0,
|
|
54938
|
-
const [wrapperRect, setWrapperRect] = (0,
|
|
54939
|
-
const [isMessageListScrolledToBottom, setIsMessageListScrolledToBottom] = (0,
|
|
54940
|
-
const closeToBottom = (0,
|
|
54941
|
-
const closeToTop = (0,
|
|
54942
|
-
const scrollToBottom = (0,
|
|
54946
|
+
const [hasNewMessages, setHasNewMessages] = (0, import_react233.useState)(false);
|
|
54947
|
+
const [wrapperRect, setWrapperRect] = (0, import_react233.useState)();
|
|
54948
|
+
const [isMessageListScrolledToBottom, setIsMessageListScrolledToBottom] = (0, import_react233.useState)(true);
|
|
54949
|
+
const closeToBottom = (0, import_react233.useRef)(false);
|
|
54950
|
+
const closeToTop = (0, import_react233.useRef)(false);
|
|
54951
|
+
const scrollToBottom = (0, import_react233.useCallback)(() => {
|
|
54943
54952
|
if (!listElement?.scrollTo || hasMoreNewer || suppressAutoscroll) {
|
|
54944
54953
|
return;
|
|
54945
54954
|
}
|
|
@@ -54948,7 +54957,7 @@ var useScrollLocationLogic = (params) => {
|
|
|
54948
54957
|
});
|
|
54949
54958
|
setHasNewMessages(false);
|
|
54950
54959
|
}, [listElement, hasMoreNewer, suppressAutoscroll]);
|
|
54951
|
-
(0,
|
|
54960
|
+
(0, import_react233.useLayoutEffect)(() => {
|
|
54952
54961
|
if (listElement) {
|
|
54953
54962
|
setWrapperRect(listElement.getBoundingClientRect());
|
|
54954
54963
|
scrollToBottom();
|
|
@@ -54968,7 +54977,7 @@ var useScrollLocationLogic = (params) => {
|
|
|
54968
54977
|
scrollToBottom,
|
|
54969
54978
|
showNewMessages: () => setHasNewMessages(true)
|
|
54970
54979
|
});
|
|
54971
|
-
const onScroll = (0,
|
|
54980
|
+
const onScroll = (0, import_react233.useCallback)(
|
|
54972
54981
|
(event) => {
|
|
54973
54982
|
const element3 = event.target;
|
|
54974
54983
|
const scrollTop = element3.scrollTop;
|
|
@@ -54999,22 +55008,22 @@ var useScrollLocationLogic = (params) => {
|
|
|
54999
55008
|
};
|
|
55000
55009
|
|
|
55001
55010
|
// src/components/MessageList/hooks/MessageList/useUnreadMessagesNotification.ts
|
|
55002
|
-
var
|
|
55011
|
+
var import_react236 = require("react");
|
|
55003
55012
|
|
|
55004
55013
|
// src/components/MessageList/MessageListMainPanel.tsx
|
|
55005
|
-
var
|
|
55014
|
+
var import_react234 = __toESM(require("react"));
|
|
55006
55015
|
var MESSAGE_LIST_MAIN_PANEL_CLASS = "str-chat__main-panel-inner str-chat__message-list-main-panel";
|
|
55007
|
-
var MessageListMainPanel = ({ children }) => /* @__PURE__ */
|
|
55016
|
+
var MessageListMainPanel = ({ children }) => /* @__PURE__ */ import_react234.default.createElement("div", { className: MESSAGE_LIST_MAIN_PANEL_CLASS }, children);
|
|
55008
55017
|
|
|
55009
55018
|
// src/components/MessageList/UnreadMessagesSeparator.tsx
|
|
55010
|
-
var
|
|
55019
|
+
var import_react235 = __toESM(require("react"));
|
|
55011
55020
|
var UNREAD_MESSAGE_SEPARATOR_CLASS = "str-chat__unread-messages-separator";
|
|
55012
55021
|
var UnreadMessagesSeparator = ({
|
|
55013
55022
|
showCount,
|
|
55014
55023
|
unreadCount
|
|
55015
55024
|
}) => {
|
|
55016
55025
|
const { t: t2 } = useTranslationContext("UnreadMessagesSeparator");
|
|
55017
|
-
return /* @__PURE__ */
|
|
55026
|
+
return /* @__PURE__ */ import_react235.default.createElement(
|
|
55018
55027
|
"div",
|
|
55019
55028
|
{
|
|
55020
55029
|
className: UNREAD_MESSAGE_SEPARATOR_CLASS,
|
|
@@ -55040,10 +55049,10 @@ var useUnreadMessagesNotification = ({
|
|
|
55040
55049
|
unreadCount
|
|
55041
55050
|
}) => {
|
|
55042
55051
|
const { messages } = useChannelStateContext("UnreadMessagesNotification");
|
|
55043
|
-
const [show, setShow] = (0,
|
|
55044
|
-
const isScrolledAboveTargetTop = (0,
|
|
55052
|
+
const [show, setShow] = (0, import_react236.useState)(false);
|
|
55053
|
+
const isScrolledAboveTargetTop = (0, import_react236.useRef)(false);
|
|
55045
55054
|
const intersectionObserverIsSupported = typeof IntersectionObserver !== "undefined";
|
|
55046
|
-
(0,
|
|
55055
|
+
(0, import_react236.useEffect)(() => {
|
|
55047
55056
|
if (!(unreadCount && intersectionObserverIsSupported)) {
|
|
55048
55057
|
setShow(false);
|
|
55049
55058
|
return;
|
|
@@ -55090,7 +55099,7 @@ var useUnreadMessagesNotification = ({
|
|
|
55090
55099
|
showAlways,
|
|
55091
55100
|
unreadCount
|
|
55092
55101
|
]);
|
|
55093
|
-
(0,
|
|
55102
|
+
(0, import_react236.useEffect)(() => {
|
|
55094
55103
|
if (unreadCount && isMessageListScrolledToBottom && isScrolledAboveTargetTop.current) {
|
|
55095
55104
|
setShow(true);
|
|
55096
55105
|
isScrolledAboveTargetTop.current = false;
|
|
@@ -55100,7 +55109,7 @@ var useUnreadMessagesNotification = ({
|
|
|
55100
55109
|
};
|
|
55101
55110
|
|
|
55102
55111
|
// src/components/MessageList/hooks/useMarkRead.ts
|
|
55103
|
-
var
|
|
55112
|
+
var import_react237 = require("react");
|
|
55104
55113
|
var hasReadLastMessage = (channel, userId) => {
|
|
55105
55114
|
const latestMessageIdInChannel = channel.state.latestMessages.slice(-1)[0]?.id;
|
|
55106
55115
|
const lastReadMessageIdServer = channel.state.read[userId]?.last_read_message_id;
|
|
@@ -55114,7 +55123,7 @@ var useMarkRead = ({
|
|
|
55114
55123
|
const { client } = useChatContext("useMarkRead");
|
|
55115
55124
|
const { markRead, setChannelUnreadUiState } = useChannelActionContext("useMarkRead");
|
|
55116
55125
|
const { channel } = useChannelStateContext("useMarkRead");
|
|
55117
|
-
(0,
|
|
55126
|
+
(0, import_react237.useEffect)(() => {
|
|
55118
55127
|
const shouldMarkRead = () => !document.hidden && !wasMarkedUnread && !messageListIsThread && isMessageListScrolledToBottom && client.user?.id && !hasReadLastMessage(channel, client.user.id);
|
|
55119
55128
|
const onVisibilityChange = () => {
|
|
55120
55129
|
if (shouldMarkRead()) markRead();
|
|
@@ -55173,11 +55182,11 @@ function getPreviousLastMessage(messages, newMessage) {
|
|
|
55173
55182
|
}
|
|
55174
55183
|
|
|
55175
55184
|
// src/components/MessageList/MessageNotification.tsx
|
|
55176
|
-
var
|
|
55185
|
+
var import_react238 = __toESM(require("react"));
|
|
55177
55186
|
var UnMemoizedMessageNotification = (props) => {
|
|
55178
55187
|
const { children, onClick, showNotification = true } = props;
|
|
55179
55188
|
if (!showNotification) return null;
|
|
55180
|
-
return /* @__PURE__ */
|
|
55189
|
+
return /* @__PURE__ */ import_react238.default.createElement(
|
|
55181
55190
|
"button",
|
|
55182
55191
|
{
|
|
55183
55192
|
"aria-live": "polite",
|
|
@@ -55188,12 +55197,12 @@ var UnMemoizedMessageNotification = (props) => {
|
|
|
55188
55197
|
children
|
|
55189
55198
|
);
|
|
55190
55199
|
};
|
|
55191
|
-
var MessageNotification =
|
|
55200
|
+
var MessageNotification = import_react238.default.memo(
|
|
55192
55201
|
UnMemoizedMessageNotification
|
|
55193
55202
|
);
|
|
55194
55203
|
|
|
55195
55204
|
// src/components/MessageList/MessageListNotifications.tsx
|
|
55196
|
-
var
|
|
55205
|
+
var import_react239 = __toESM(require("react"));
|
|
55197
55206
|
var MessageListNotifications = (props) => {
|
|
55198
55207
|
const {
|
|
55199
55208
|
hasNewMessages,
|
|
@@ -55206,7 +55215,7 @@ var MessageListNotifications = (props) => {
|
|
|
55206
55215
|
unreadCount
|
|
55207
55216
|
} = props;
|
|
55208
55217
|
const { t: t2 } = useTranslationContext("MessageListNotifications");
|
|
55209
|
-
return /* @__PURE__ */
|
|
55218
|
+
return /* @__PURE__ */ import_react239.default.createElement("div", { className: "str-chat__list-notifications" }, notifications.map((notification) => /* @__PURE__ */ import_react239.default.createElement(CustomNotification, { active: true, key: notification.id, type: notification.type }, notification.text)), /* @__PURE__ */ import_react239.default.createElement(ConnectionStatus, null), /* @__PURE__ */ import_react239.default.createElement(
|
|
55210
55219
|
MessageNotification2,
|
|
55211
55220
|
{
|
|
55212
55221
|
isMessageListScrolledToBottom,
|
|
@@ -55220,11 +55229,11 @@ var MessageListNotifications = (props) => {
|
|
|
55220
55229
|
};
|
|
55221
55230
|
|
|
55222
55231
|
// src/components/MessageList/UnreadMessagesNotification.tsx
|
|
55223
|
-
var
|
|
55232
|
+
var import_react241 = __toESM(require("react"));
|
|
55224
55233
|
|
|
55225
55234
|
// src/components/MessageList/icons.tsx
|
|
55226
|
-
var
|
|
55227
|
-
var ArrowDown = ({ className, color: color2 }) => /* @__PURE__ */
|
|
55235
|
+
var import_react240 = __toESM(require("react"));
|
|
55236
|
+
var ArrowDown = ({ className, color: color2 }) => /* @__PURE__ */ import_react240.default.createElement(
|
|
55228
55237
|
"svg",
|
|
55229
55238
|
{
|
|
55230
55239
|
className,
|
|
@@ -55235,7 +55244,7 @@ var ArrowDown = ({ className, color: color2 }) => /* @__PURE__ */ import_react23
|
|
|
55235
55244
|
width: "24",
|
|
55236
55245
|
xmlns: "http://www.w3.org/2000/svg"
|
|
55237
55246
|
},
|
|
55238
|
-
/* @__PURE__ */
|
|
55247
|
+
/* @__PURE__ */ import_react240.default.createElement(
|
|
55239
55248
|
"path",
|
|
55240
55249
|
{
|
|
55241
55250
|
d: "M7.41 8.29504L12 12.875L16.59 8.29504L18 9.70504L12 15.705L6 9.70504L7.41 8.29504Z",
|
|
@@ -55243,7 +55252,7 @@ var ArrowDown = ({ className, color: color2 }) => /* @__PURE__ */ import_react23
|
|
|
55243
55252
|
}
|
|
55244
55253
|
)
|
|
55245
55254
|
);
|
|
55246
|
-
var CloseIcon2 = () => /* @__PURE__ */
|
|
55255
|
+
var CloseIcon2 = () => /* @__PURE__ */ import_react240.default.createElement("svg", { fill: "currentColor", viewBox: "0 0 14 13", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react240.default.createElement("path", { d: "M1.32227 12.3408C0.944336 11.9629 0.953125 11.3213 1.32227 10.9521L5.60254 6.66309L1.32227 2.38281C0.953125 2.01367 0.944336 1.37207 1.32227 0.994141C1.7002 0.616211 2.3418 0.625 2.71094 0.985352L7 5.27441L11.2803 0.994141C11.6494 0.625 12.291 0.616211 12.6689 0.994141C13.0469 1.37207 13.0381 2.01367 12.6689 2.38281L8.38867 6.66309L12.6689 10.9521C13.0381 11.3213 13.0469 11.9629 12.6689 12.3408C12.291 12.7188 11.6494 12.71 11.2803 12.3408L7 8.06055L2.71094 12.3408C2.3418 12.71 1.7002 12.7188 1.32227 12.3408Z" }));
|
|
55247
55256
|
|
|
55248
55257
|
// src/components/MessageList/UnreadMessagesNotification.tsx
|
|
55249
55258
|
var UnreadMessagesNotification = ({
|
|
@@ -55255,19 +55264,19 @@ var UnreadMessagesNotification = ({
|
|
|
55255
55264
|
"UnreadMessagesNotification"
|
|
55256
55265
|
);
|
|
55257
55266
|
const { t: t2 } = useTranslationContext("UnreadMessagesNotification");
|
|
55258
|
-
return /* @__PURE__ */
|
|
55267
|
+
return /* @__PURE__ */ import_react241.default.createElement(
|
|
55259
55268
|
"div",
|
|
55260
55269
|
{
|
|
55261
55270
|
className: "str-chat__unread-messages-notification",
|
|
55262
55271
|
"data-testid": "unread-messages-notification"
|
|
55263
55272
|
},
|
|
55264
|
-
/* @__PURE__ */
|
|
55265
|
-
/* @__PURE__ */
|
|
55273
|
+
/* @__PURE__ */ import_react241.default.createElement("button", { onClick: () => jumpToFirstUnreadMessage(queryMessageLimit) }, unreadCount && showCount ? t2("{{count}} unread", { count: unreadCount ?? 0 }) : t2("Unread messages")),
|
|
55274
|
+
/* @__PURE__ */ import_react241.default.createElement("button", { onClick: () => markRead() }, /* @__PURE__ */ import_react241.default.createElement(CloseIcon2, null))
|
|
55266
55275
|
);
|
|
55267
55276
|
};
|
|
55268
55277
|
|
|
55269
55278
|
// src/components/InfiniteScrollPaginator/InfiniteScroll.tsx
|
|
55270
|
-
var
|
|
55279
|
+
var import_react242 = __toESM(require("react"));
|
|
55271
55280
|
var mousewheelListener2 = (event) => {
|
|
55272
55281
|
if (event instanceof WheelEvent && event.deltaY === 1) {
|
|
55273
55282
|
event.preventDefault();
|
|
@@ -55298,10 +55307,10 @@ var InfiniteScroll = (props) => {
|
|
|
55298
55307
|
const loadPreviousPageFn = loadPreviousPage || loadMore;
|
|
55299
55308
|
const hasNextPageFlag = hasNextPage || hasMoreNewer;
|
|
55300
55309
|
const hasPreviousPageFlag = hasPreviousPage || hasMore;
|
|
55301
|
-
const scrollComponent = (0,
|
|
55302
|
-
const previousOffset = (0,
|
|
55303
|
-
const previousReverseOffset = (0,
|
|
55304
|
-
const scrollListenerRef = (0,
|
|
55310
|
+
const scrollComponent = (0, import_react242.useRef)(void 0);
|
|
55311
|
+
const previousOffset = (0, import_react242.useRef)(void 0);
|
|
55312
|
+
const previousReverseOffset = (0, import_react242.useRef)(void 0);
|
|
55313
|
+
const scrollListenerRef = (0, import_react242.useRef)(void 0);
|
|
55305
55314
|
scrollListenerRef.current = () => {
|
|
55306
55315
|
const element4 = scrollComponent.current;
|
|
55307
55316
|
if (!element4 || element4.offsetParent === null) {
|
|
@@ -55325,7 +55334,7 @@ var InfiniteScroll = (props) => {
|
|
|
55325
55334
|
loadNextPageFn();
|
|
55326
55335
|
}
|
|
55327
55336
|
};
|
|
55328
|
-
(0,
|
|
55337
|
+
(0, import_react242.useEffect)(() => {
|
|
55329
55338
|
deprecationAndReplacementWarning(
|
|
55330
55339
|
[
|
|
55331
55340
|
[{ hasMoreNewer }, { hasNextPage }],
|
|
@@ -55336,7 +55345,7 @@ var InfiniteScroll = (props) => {
|
|
|
55336
55345
|
"InfiniteScroll"
|
|
55337
55346
|
);
|
|
55338
55347
|
}, []);
|
|
55339
|
-
(0,
|
|
55348
|
+
(0, import_react242.useEffect)(() => {
|
|
55340
55349
|
const scrollElement = scrollComponent.current?.parentNode;
|
|
55341
55350
|
if (!scrollElement) return;
|
|
55342
55351
|
const scrollListener = () => scrollListenerRef.current?.();
|
|
@@ -55348,7 +55357,7 @@ var InfiniteScroll = (props) => {
|
|
|
55348
55357
|
scrollElement.removeEventListener("resize", scrollListener, useCapture);
|
|
55349
55358
|
};
|
|
55350
55359
|
}, [initialLoad, useCapture]);
|
|
55351
|
-
(0,
|
|
55360
|
+
(0, import_react242.useEffect)(() => {
|
|
55352
55361
|
const scrollElement = scrollComponent.current?.parentNode;
|
|
55353
55362
|
if (scrollElement) {
|
|
55354
55363
|
scrollElement.addEventListener("wheel", mousewheelListener2, { passive: false });
|
|
@@ -55369,11 +55378,11 @@ var InfiniteScroll = (props) => {
|
|
|
55369
55378
|
if (head) {
|
|
55370
55379
|
childrenArray.unshift(head);
|
|
55371
55380
|
}
|
|
55372
|
-
return
|
|
55381
|
+
return import_react242.default.createElement(element3, attributes, childrenArray);
|
|
55373
55382
|
};
|
|
55374
55383
|
|
|
55375
55384
|
// src/components/TypingIndicator/TypingIndicator.tsx
|
|
55376
|
-
var
|
|
55385
|
+
var import_react243 = __toESM(require("react"));
|
|
55377
55386
|
var import_clsx61 = __toESM(require("clsx"));
|
|
55378
55387
|
var useJoinTypingUsers = (names) => {
|
|
55379
55388
|
const { t: t2 } = useTranslationContext();
|
|
@@ -55411,7 +55420,7 @@ var UnMemoizedTypingIndicator = (props) => {
|
|
|
55411
55420
|
return null;
|
|
55412
55421
|
}
|
|
55413
55422
|
if (!isTypingActive) return null;
|
|
55414
|
-
return /* @__PURE__ */
|
|
55423
|
+
return /* @__PURE__ */ import_react243.default.createElement(
|
|
55415
55424
|
"div",
|
|
55416
55425
|
{
|
|
55417
55426
|
className: (0, import_clsx61.default)("str-chat__typing-indicator", {
|
|
@@ -55419,19 +55428,19 @@ var UnMemoizedTypingIndicator = (props) => {
|
|
|
55419
55428
|
}),
|
|
55420
55429
|
"data-testid": "typing-indicator"
|
|
55421
55430
|
},
|
|
55422
|
-
/* @__PURE__ */
|
|
55423
|
-
/* @__PURE__ */
|
|
55431
|
+
/* @__PURE__ */ import_react243.default.createElement("div", { className: "str-chat__typing-indicator__dots" }, /* @__PURE__ */ import_react243.default.createElement("span", { className: "str-chat__typing-indicator__dot" }), /* @__PURE__ */ import_react243.default.createElement("span", { className: "str-chat__typing-indicator__dot" }), /* @__PURE__ */ import_react243.default.createElement("span", { className: "str-chat__typing-indicator__dot" })),
|
|
55432
|
+
/* @__PURE__ */ import_react243.default.createElement("div", { className: "str-chat__typing-indicator__users", "data-testid": "typing-users" }, joinedTypingUsers)
|
|
55424
55433
|
);
|
|
55425
55434
|
};
|
|
55426
|
-
var TypingIndicator =
|
|
55435
|
+
var TypingIndicator = import_react243.default.memo(
|
|
55427
55436
|
UnMemoizedTypingIndicator
|
|
55428
55437
|
);
|
|
55429
55438
|
|
|
55430
55439
|
// src/components/MessageList/renderMessages.tsx
|
|
55431
|
-
var
|
|
55440
|
+
var import_react246 = __toESM(require("react"));
|
|
55432
55441
|
|
|
55433
55442
|
// src/components/DateSeparator/DateSeparator.tsx
|
|
55434
|
-
var
|
|
55443
|
+
var import_react244 = __toESM(require("react"));
|
|
55435
55444
|
var UnMemoizedDateSeparator = (props) => {
|
|
55436
55445
|
const {
|
|
55437
55446
|
calendar: calendar3,
|
|
@@ -55451,21 +55460,21 @@ var UnMemoizedDateSeparator = (props) => {
|
|
|
55451
55460
|
tDateTimeParser,
|
|
55452
55461
|
timestampTranslationKey: "timestamp/DateSeparator"
|
|
55453
55462
|
});
|
|
55454
|
-
return /* @__PURE__ */
|
|
55463
|
+
return /* @__PURE__ */ import_react244.default.createElement("div", { className: "str-chat__date-separator", "data-testid": "date-separator" }, (position4 === "right" || position4 === "center") && /* @__PURE__ */ import_react244.default.createElement("hr", { className: "str-chat__date-separator-line" }), /* @__PURE__ */ import_react244.default.createElement("div", { className: "str-chat__date-separator-date" }, unread ? `${t2("New")} - ${formattedDate}` : formattedDate), (position4 === "left" || position4 === "center") && /* @__PURE__ */ import_react244.default.createElement("hr", { className: "str-chat__date-separator-line" }));
|
|
55455
55464
|
};
|
|
55456
|
-
var DateSeparator =
|
|
55465
|
+
var DateSeparator = import_react244.default.memo(
|
|
55457
55466
|
UnMemoizedDateSeparator
|
|
55458
55467
|
);
|
|
55459
55468
|
|
|
55460
55469
|
// src/components/EventComponent/EventComponent.tsx
|
|
55461
|
-
var
|
|
55470
|
+
var import_react245 = __toESM(require("react"));
|
|
55462
55471
|
var UnMemoizedEventComponent = (props) => {
|
|
55463
55472
|
const { Avatar: Avatar2 = Avatar, calendar: calendar3, calendarFormats, format, message } = props;
|
|
55464
55473
|
const { t: t2, tDateTimeParser } = useTranslationContext("EventComponent");
|
|
55465
55474
|
const { created_at = "", event, text: text7, type } = message;
|
|
55466
55475
|
const getDateOptions = { messageCreatedAt: created_at.toString(), tDateTimeParser };
|
|
55467
55476
|
if (type === "system")
|
|
55468
|
-
return /* @__PURE__ */
|
|
55477
|
+
return /* @__PURE__ */ import_react245.default.createElement("div", { className: "str-chat__message--system", "data-testid": "message-system" }, /* @__PURE__ */ import_react245.default.createElement("div", { className: "str-chat__message--system__text" }, /* @__PURE__ */ import_react245.default.createElement("div", { className: "str-chat__message--system__line" }), /* @__PURE__ */ import_react245.default.createElement("p", null, text7), /* @__PURE__ */ import_react245.default.createElement("div", { className: "str-chat__message--system__line" })), /* @__PURE__ */ import_react245.default.createElement("div", { className: "str-chat__message--system__date" }, /* @__PURE__ */ import_react245.default.createElement("strong", null, getDateString({
|
|
55469
55478
|
...getDateOptions,
|
|
55470
55479
|
calendar: calendar3,
|
|
55471
55480
|
calendarFormats,
|
|
@@ -55476,11 +55485,11 @@ var UnMemoizedEventComponent = (props) => {
|
|
|
55476
55485
|
if (event?.type === "member.removed" || event?.type === "member.added") {
|
|
55477
55486
|
const name2 = event.user?.name || event.user?.id;
|
|
55478
55487
|
const sentence = `${name2} ${event.type === "member.added" ? "has joined the chat" : "was removed from the chat"}`;
|
|
55479
|
-
return /* @__PURE__ */
|
|
55488
|
+
return /* @__PURE__ */ import_react245.default.createElement("div", { className: "str-chat__event-component__channel-event" }, /* @__PURE__ */ import_react245.default.createElement(Avatar2, { image: event.user?.image, name: name2, user: event.user }), /* @__PURE__ */ import_react245.default.createElement("div", { className: "str-chat__event-component__channel-event__content" }, /* @__PURE__ */ import_react245.default.createElement("em", { className: "str-chat__event-component__channel-event__sentence" }, sentence), /* @__PURE__ */ import_react245.default.createElement("div", { className: "str-chat__event-component__channel-event__date" }, getDateString({ ...getDateOptions, format: "LT" }))));
|
|
55480
55489
|
}
|
|
55481
55490
|
return null;
|
|
55482
55491
|
};
|
|
55483
|
-
var EventComponent =
|
|
55492
|
+
var EventComponent = import_react245.default.memo(
|
|
55484
55493
|
UnMemoizedEventComponent
|
|
55485
55494
|
);
|
|
55486
55495
|
|
|
@@ -55508,7 +55517,7 @@ function defaultRenderMessages({
|
|
|
55508
55517
|
const message = messages[index3];
|
|
55509
55518
|
if (isDateSeparatorMessage(message)) {
|
|
55510
55519
|
renderedMessages.push(
|
|
55511
|
-
/* @__PURE__ */
|
|
55520
|
+
/* @__PURE__ */ import_react246.default.createElement("li", { key: `${message.date.toISOString()}-i` }, /* @__PURE__ */ import_react246.default.createElement(
|
|
55512
55521
|
DateSeparator2,
|
|
55513
55522
|
{
|
|
55514
55523
|
date: message.date,
|
|
@@ -55519,17 +55528,17 @@ function defaultRenderMessages({
|
|
|
55519
55528
|
);
|
|
55520
55529
|
} else if (message.customType === CUSTOM_MESSAGE_TYPE.intro && HeaderComponent) {
|
|
55521
55530
|
renderedMessages.push(
|
|
55522
|
-
/* @__PURE__ */
|
|
55531
|
+
/* @__PURE__ */ import_react246.default.createElement("li", { key: "intro" }, /* @__PURE__ */ import_react246.default.createElement(HeaderComponent, null))
|
|
55523
55532
|
);
|
|
55524
55533
|
} else if (message.type === "system") {
|
|
55525
55534
|
renderedMessages.push(
|
|
55526
|
-
/* @__PURE__ */
|
|
55535
|
+
/* @__PURE__ */ import_react246.default.createElement(
|
|
55527
55536
|
"li",
|
|
55528
55537
|
{
|
|
55529
55538
|
"data-message-id": message.id,
|
|
55530
55539
|
key: message.id || message.created_at
|
|
55531
55540
|
},
|
|
55532
|
-
/* @__PURE__ */
|
|
55541
|
+
/* @__PURE__ */ import_react246.default.createElement(MessageSystem, { message })
|
|
55533
55542
|
)
|
|
55534
55543
|
);
|
|
55535
55544
|
} else {
|
|
@@ -55548,19 +55557,19 @@ function defaultRenderMessages({
|
|
|
55548
55557
|
unreadMessageCount: channelUnreadUiState?.unread_messages
|
|
55549
55558
|
});
|
|
55550
55559
|
renderedMessages.push(
|
|
55551
|
-
/* @__PURE__ */
|
|
55560
|
+
/* @__PURE__ */ import_react246.default.createElement(import_react246.Fragment, { key: message.id || message.created_at }, isFirstUnreadMessage && UnreadMessagesSeparator2 && /* @__PURE__ */ import_react246.default.createElement("li", { className: "str-chat__li str-chat__unread-messages-separator-wrapper" }, /* @__PURE__ */ import_react246.default.createElement(
|
|
55552
55561
|
UnreadMessagesSeparator2,
|
|
55553
55562
|
{
|
|
55554
55563
|
unreadCount: channelUnreadUiState?.unread_messages
|
|
55555
55564
|
}
|
|
55556
|
-
)), /* @__PURE__ */
|
|
55565
|
+
)), /* @__PURE__ */ import_react246.default.createElement(
|
|
55557
55566
|
"li",
|
|
55558
55567
|
{
|
|
55559
55568
|
className: messageClass,
|
|
55560
55569
|
"data-message-id": message.id,
|
|
55561
55570
|
"data-testid": messageClass
|
|
55562
55571
|
},
|
|
55563
|
-
/* @__PURE__ */
|
|
55572
|
+
/* @__PURE__ */ import_react246.default.createElement(
|
|
55564
55573
|
Message,
|
|
55565
55574
|
{
|
|
55566
55575
|
groupStyles: [groupStyles],
|
|
@@ -55617,8 +55626,8 @@ var MessageListWithContext = (props) => {
|
|
|
55617
55626
|
threadList = false,
|
|
55618
55627
|
unsafeHTML = false
|
|
55619
55628
|
} = props;
|
|
55620
|
-
const [listElement, setListElement] =
|
|
55621
|
-
const [ulElement, setUlElement] =
|
|
55629
|
+
const [listElement, setListElement] = import_react247.default.useState(null);
|
|
55630
|
+
const [ulElement, setUlElement] = import_react247.default.useState(null);
|
|
55622
55631
|
const { customClasses } = useChatContext("MessageList");
|
|
55623
55632
|
const {
|
|
55624
55633
|
EmptyStateIndicator: EmptyStateIndicator2 = EmptyStateIndicator,
|
|
@@ -55706,24 +55715,24 @@ var MessageListWithContext = (props) => {
|
|
|
55706
55715
|
threadList
|
|
55707
55716
|
});
|
|
55708
55717
|
const messageListClass = customClasses?.messageList || "str-chat__list";
|
|
55709
|
-
const loadMore =
|
|
55718
|
+
const loadMore = import_react247.default.useCallback(() => {
|
|
55710
55719
|
if (loadMoreCallback) {
|
|
55711
55720
|
loadMoreCallback(messageLimit);
|
|
55712
55721
|
}
|
|
55713
55722
|
}, [loadMoreCallback, messageLimit]);
|
|
55714
|
-
const loadMoreNewer =
|
|
55723
|
+
const loadMoreNewer = import_react247.default.useCallback(() => {
|
|
55715
55724
|
if (loadMoreNewerCallback) {
|
|
55716
55725
|
loadMoreNewerCallback(messageLimit);
|
|
55717
55726
|
}
|
|
55718
55727
|
}, [loadMoreNewerCallback, messageLimit]);
|
|
55719
|
-
const scrollToBottomFromNotification =
|
|
55728
|
+
const scrollToBottomFromNotification = import_react247.default.useCallback(async () => {
|
|
55720
55729
|
if (hasMoreNewer) {
|
|
55721
55730
|
await jumpToLatestMessage();
|
|
55722
55731
|
} else {
|
|
55723
55732
|
scrollToBottom();
|
|
55724
55733
|
}
|
|
55725
55734
|
}, [scrollToBottom, hasMoreNewer]);
|
|
55726
|
-
|
|
55735
|
+
import_react247.default.useLayoutEffect(() => {
|
|
55727
55736
|
if (highlightedMessageId) {
|
|
55728
55737
|
const element3 = ulElement?.querySelector(
|
|
55729
55738
|
`[data-message-id='${highlightedMessageId}']`
|
|
@@ -55731,14 +55740,15 @@ var MessageListWithContext = (props) => {
|
|
|
55731
55740
|
element3?.scrollIntoView({ block: "center" });
|
|
55732
55741
|
}
|
|
55733
55742
|
}, [highlightedMessageId]);
|
|
55743
|
+
const id = useStableId();
|
|
55734
55744
|
const showEmptyStateIndicator = elements.length === 0 && !threadList;
|
|
55735
|
-
const dialogManagerId = threadList ?
|
|
55736
|
-
return /* @__PURE__ */
|
|
55745
|
+
const dialogManagerId = threadList ? `message-list-dialog-manager-thread-${id}` : `message-list-dialog-manager-${id}`;
|
|
55746
|
+
return /* @__PURE__ */ import_react247.default.createElement(MessageListContextProvider, { value: { listElement, scrollToBottom } }, /* @__PURE__ */ import_react247.default.createElement(MessageListMainPanel2, null, /* @__PURE__ */ import_react247.default.createElement(DialogManagerProvider, { id: dialogManagerId }, !threadList && showUnreadMessagesNotification && /* @__PURE__ */ import_react247.default.createElement(
|
|
55737
55747
|
UnreadMessagesNotification2,
|
|
55738
55748
|
{
|
|
55739
55749
|
unreadCount: channelUnreadUiState?.unread_messages
|
|
55740
55750
|
}
|
|
55741
|
-
), /* @__PURE__ */
|
|
55751
|
+
), /* @__PURE__ */ import_react247.default.createElement(
|
|
55742
55752
|
"div",
|
|
55743
55753
|
{
|
|
55744
55754
|
className: (0, import_clsx62.default)(messageListClass, customClasses?.threadList),
|
|
@@ -55746,7 +55756,7 @@ var MessageListWithContext = (props) => {
|
|
|
55746
55756
|
ref: setListElement,
|
|
55747
55757
|
tabIndex: 0
|
|
55748
55758
|
},
|
|
55749
|
-
showEmptyStateIndicator ? /* @__PURE__ */
|
|
55759
|
+
showEmptyStateIndicator ? /* @__PURE__ */ import_react247.default.createElement(EmptyStateIndicator2, { listType: threadList ? "thread" : "message" }) : /* @__PURE__ */ import_react247.default.createElement(
|
|
55750
55760
|
InfiniteScroll,
|
|
55751
55761
|
{
|
|
55752
55762
|
className: "str-chat__message-list-scroll",
|
|
@@ -55755,17 +55765,17 @@ var MessageListWithContext = (props) => {
|
|
|
55755
55765
|
hasPreviousPage: props.hasMore,
|
|
55756
55766
|
head: props.head,
|
|
55757
55767
|
isLoading: props.loadingMore,
|
|
55758
|
-
loader: /* @__PURE__ */
|
|
55768
|
+
loader: /* @__PURE__ */ import_react247.default.createElement("div", { className: "str-chat__list__loading", key: "loading-indicator" }, props.loadingMore && /* @__PURE__ */ import_react247.default.createElement(LoadingIndicator2, { size: 20 })),
|
|
55759
55769
|
loadNextPage: loadMoreNewer,
|
|
55760
55770
|
loadPreviousPage: loadMore,
|
|
55761
55771
|
threshold: loadMoreScrollThreshold,
|
|
55762
55772
|
...restInternalInfiniteScrollProps
|
|
55763
55773
|
},
|
|
55764
|
-
/* @__PURE__ */
|
|
55765
|
-
/* @__PURE__ */
|
|
55766
|
-
/* @__PURE__ */
|
|
55774
|
+
/* @__PURE__ */ import_react247.default.createElement("ul", { className: "str-chat__ul", ref: setUlElement }, elements),
|
|
55775
|
+
/* @__PURE__ */ import_react247.default.createElement(TypingIndicator2, { threadList }),
|
|
55776
|
+
/* @__PURE__ */ import_react247.default.createElement("div", { key: "bottom" })
|
|
55767
55777
|
)
|
|
55768
|
-
))), /* @__PURE__ */
|
|
55778
|
+
))), /* @__PURE__ */ import_react247.default.createElement(
|
|
55769
55779
|
MessageListNotifications2,
|
|
55770
55780
|
{
|
|
55771
55781
|
hasNewMessages,
|
|
@@ -55790,7 +55800,7 @@ var MessageList = (props) => {
|
|
|
55790
55800
|
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
55791
55801
|
...restChannelStateContext
|
|
55792
55802
|
} = useChannelStateContext("MessageList");
|
|
55793
|
-
return /* @__PURE__ */
|
|
55803
|
+
return /* @__PURE__ */ import_react247.default.createElement(
|
|
55794
55804
|
MessageListWithContext,
|
|
55795
55805
|
{
|
|
55796
55806
|
jumpToLatestMessage,
|
|
@@ -55803,16 +55813,16 @@ var MessageList = (props) => {
|
|
|
55803
55813
|
};
|
|
55804
55814
|
|
|
55805
55815
|
// src/components/MessageList/ScrollToBottomButton.tsx
|
|
55806
|
-
var
|
|
55816
|
+
var import_react248 = __toESM(require("react"));
|
|
55807
55817
|
var import_clsx63 = __toESM(require("clsx"));
|
|
55808
55818
|
var UnMemoizedScrollToBottomButton = (props) => {
|
|
55809
55819
|
const { isMessageListScrolledToBottom, onClick, threadList } = props;
|
|
55810
55820
|
const { channel: activeChannel, client } = useChatContext();
|
|
55811
55821
|
const { thread } = useChannelStateContext();
|
|
55812
|
-
const [countUnread, setCountUnread] = (0,
|
|
55813
|
-
const [replyCount, setReplyCount] = (0,
|
|
55822
|
+
const [countUnread, setCountUnread] = (0, import_react248.useState)(activeChannel?.countUnread() || 0);
|
|
55823
|
+
const [replyCount, setReplyCount] = (0, import_react248.useState)(thread?.reply_count || 0);
|
|
55814
55824
|
const observedEvent = threadList ? "message.updated" : "message.new";
|
|
55815
|
-
(0,
|
|
55825
|
+
(0, import_react248.useEffect)(() => {
|
|
55816
55826
|
const handleEvent = (event) => {
|
|
55817
55827
|
const newMessageInAnotherChannel = event.cid !== activeChannel?.cid;
|
|
55818
55828
|
const newMessageIsMine = event.user?.id === client.user?.id;
|
|
@@ -55834,14 +55844,14 @@ var UnMemoizedScrollToBottomButton = (props) => {
|
|
|
55834
55844
|
client.off(observedEvent, handleEvent);
|
|
55835
55845
|
};
|
|
55836
55846
|
}, [activeChannel, isMessageListScrolledToBottom, observedEvent, replyCount, thread]);
|
|
55837
|
-
(0,
|
|
55847
|
+
(0, import_react248.useEffect)(() => {
|
|
55838
55848
|
if (isMessageListScrolledToBottom) {
|
|
55839
55849
|
setCountUnread(0);
|
|
55840
55850
|
setReplyCount(thread?.reply_count || 0);
|
|
55841
55851
|
}
|
|
55842
55852
|
}, [isMessageListScrolledToBottom, thread]);
|
|
55843
55853
|
if (isMessageListScrolledToBottom) return null;
|
|
55844
|
-
return /* @__PURE__ */
|
|
55854
|
+
return /* @__PURE__ */ import_react248.default.createElement("div", { className: "str-chat__jump-to-latest-message" }, /* @__PURE__ */ import_react248.default.createElement(
|
|
55845
55855
|
"button",
|
|
55846
55856
|
{
|
|
55847
55857
|
"aria-live": "polite",
|
|
@@ -55852,8 +55862,8 @@ var UnMemoizedScrollToBottomButton = (props) => {
|
|
|
55852
55862
|
"data-testid": "message-notification",
|
|
55853
55863
|
onClick
|
|
55854
55864
|
},
|
|
55855
|
-
/* @__PURE__ */
|
|
55856
|
-
countUnread > 0 && /* @__PURE__ */
|
|
55865
|
+
/* @__PURE__ */ import_react248.default.createElement(ArrowDown, null),
|
|
55866
|
+
countUnread > 0 && /* @__PURE__ */ import_react248.default.createElement(
|
|
55857
55867
|
"div",
|
|
55858
55868
|
{
|
|
55859
55869
|
className: (0, import_clsx63.default)(
|
|
@@ -55866,23 +55876,23 @@ var UnMemoizedScrollToBottomButton = (props) => {
|
|
|
55866
55876
|
)
|
|
55867
55877
|
));
|
|
55868
55878
|
};
|
|
55869
|
-
var ScrollToBottomButton =
|
|
55879
|
+
var ScrollToBottomButton = import_react248.default.memo(
|
|
55870
55880
|
UnMemoizedScrollToBottomButton
|
|
55871
55881
|
);
|
|
55872
55882
|
|
|
55873
55883
|
// src/components/MessageList/VirtualizedMessageList.tsx
|
|
55874
|
-
var
|
|
55884
|
+
var import_react258 = __toESM(require("react"));
|
|
55875
55885
|
var import_react_virtuoso2 = require("react-virtuoso");
|
|
55876
55886
|
|
|
55877
55887
|
// src/components/MessageList/hooks/VirtualizedMessageList/useNewMessageNotification.ts
|
|
55878
|
-
var
|
|
55888
|
+
var import_react249 = require("react");
|
|
55879
55889
|
function useNewMessageNotification(messages, currentUserId, hasMoreNewer) {
|
|
55880
|
-
const [newMessagesNotification, setNewMessagesNotification] = (0,
|
|
55881
|
-
const [isMessageListScrolledToBottom, setIsMessageListScrolledToBottom] = (0,
|
|
55882
|
-
const didMount = (0,
|
|
55883
|
-
const lastMessageId = (0,
|
|
55884
|
-
const atBottom = (0,
|
|
55885
|
-
(0,
|
|
55890
|
+
const [newMessagesNotification, setNewMessagesNotification] = (0, import_react249.useState)(false);
|
|
55891
|
+
const [isMessageListScrolledToBottom, setIsMessageListScrolledToBottom] = (0, import_react249.useState)(true);
|
|
55892
|
+
const didMount = (0, import_react249.useRef)(false);
|
|
55893
|
+
const lastMessageId = (0, import_react249.useRef)("");
|
|
55894
|
+
const atBottom = (0, import_react249.useRef)(false);
|
|
55895
|
+
(0, import_react249.useEffect)(() => {
|
|
55886
55896
|
if (hasMoreNewer) {
|
|
55887
55897
|
setNewMessagesNotification(true);
|
|
55888
55898
|
return;
|
|
@@ -55908,17 +55918,17 @@ function useNewMessageNotification(messages, currentUserId, hasMoreNewer) {
|
|
|
55908
55918
|
}
|
|
55909
55919
|
|
|
55910
55920
|
// src/components/MessageList/hooks/VirtualizedMessageList/usePrependMessagesCount.ts
|
|
55911
|
-
var
|
|
55921
|
+
var import_react250 = require("react");
|
|
55912
55922
|
var STATUSES_EXCLUDED_FROM_PREPEND = {
|
|
55913
55923
|
failed: true,
|
|
55914
55924
|
sending: true
|
|
55915
55925
|
};
|
|
55916
55926
|
function usePrependedMessagesCount(messages, hasDateSeparator) {
|
|
55917
55927
|
const firstRealMessageIndex = hasDateSeparator ? 1 : 0;
|
|
55918
|
-
const firstMessageOnFirstLoadedPage = (0,
|
|
55919
|
-
const previousFirstMessageOnFirstLoadedPage = (0,
|
|
55920
|
-
const previousNumItemsPrepended = (0,
|
|
55921
|
-
const numItemsPrepended = (0,
|
|
55928
|
+
const firstMessageOnFirstLoadedPage = (0, import_react250.useRef)(void 0);
|
|
55929
|
+
const previousFirstMessageOnFirstLoadedPage = (0, import_react250.useRef)(void 0);
|
|
55930
|
+
const previousNumItemsPrepended = (0, import_react250.useRef)(0);
|
|
55931
|
+
const numItemsPrepended = (0, import_react250.useMemo)(() => {
|
|
55922
55932
|
if (!messages || !messages.length) {
|
|
55923
55933
|
previousNumItemsPrepended.current = 0;
|
|
55924
55934
|
return 0;
|
|
@@ -55948,10 +55958,10 @@ function usePrependedMessagesCount(messages, hasDateSeparator) {
|
|
|
55948
55958
|
}
|
|
55949
55959
|
|
|
55950
55960
|
// src/components/MessageList/hooks/VirtualizedMessageList/useShouldForceScrollToBottom.ts
|
|
55951
|
-
var
|
|
55961
|
+
var import_react251 = require("react");
|
|
55952
55962
|
function useShouldForceScrollToBottom(messages, currentUserId) {
|
|
55953
|
-
const lastFocusedOwnMessage = (0,
|
|
55954
|
-
const initialFocusRegistered = (0,
|
|
55963
|
+
const lastFocusedOwnMessage = (0, import_react251.useRef)("");
|
|
55964
|
+
const initialFocusRegistered = (0, import_react251.useRef)(false);
|
|
55955
55965
|
function recheckForNewOwnMessage() {
|
|
55956
55966
|
if (messages && messages.length > 0) {
|
|
55957
55967
|
const lastMessage = messages[messages.length - 1];
|
|
@@ -55962,7 +55972,7 @@ function useShouldForceScrollToBottom(messages, currentUserId) {
|
|
|
55962
55972
|
}
|
|
55963
55973
|
return false;
|
|
55964
55974
|
}
|
|
55965
|
-
(0,
|
|
55975
|
+
(0, import_react251.useEffect)(() => {
|
|
55966
55976
|
if (messages && messages.length && !initialFocusRegistered.current) {
|
|
55967
55977
|
initialFocusRegistered.current = true;
|
|
55968
55978
|
recheckForNewOwnMessage();
|
|
@@ -55972,11 +55982,11 @@ function useShouldForceScrollToBottom(messages, currentUserId) {
|
|
|
55972
55982
|
}
|
|
55973
55983
|
|
|
55974
55984
|
// src/components/MessageList/hooks/VirtualizedMessageList/useGiphyPreview.ts
|
|
55975
|
-
var
|
|
55985
|
+
var import_react252 = require("react");
|
|
55976
55986
|
var useGiphyPreview = (separateGiphyPreview) => {
|
|
55977
|
-
const [giphyPreviewMessage, setGiphyPreviewMessage] = (0,
|
|
55987
|
+
const [giphyPreviewMessage, setGiphyPreviewMessage] = (0, import_react252.useState)();
|
|
55978
55988
|
const { client } = useChatContext("useGiphyPreview");
|
|
55979
|
-
(0,
|
|
55989
|
+
(0, import_react252.useEffect)(() => {
|
|
55980
55990
|
const handleEvent = (event) => {
|
|
55981
55991
|
const { message, user } = event;
|
|
55982
55992
|
if (message?.command === "giphy" && user?.id === client.userID) {
|
|
@@ -55993,13 +56003,13 @@ var useGiphyPreview = (separateGiphyPreview) => {
|
|
|
55993
56003
|
};
|
|
55994
56004
|
|
|
55995
56005
|
// src/components/MessageList/hooks/VirtualizedMessageList/useMessageSetKey.ts
|
|
55996
|
-
var
|
|
56006
|
+
var import_react253 = require("react");
|
|
55997
56007
|
var useMessageSetKey = ({
|
|
55998
56008
|
messages
|
|
55999
56009
|
}) => {
|
|
56000
|
-
const [messageSetKey, setMessageSetKey] = (0,
|
|
56001
|
-
const firstMessageId = (0,
|
|
56002
|
-
(0,
|
|
56010
|
+
const [messageSetKey, setMessageSetKey] = (0, import_react253.useState)(+/* @__PURE__ */ new Date());
|
|
56011
|
+
const firstMessageId = (0, import_react253.useRef)(void 0);
|
|
56012
|
+
(0, import_react253.useEffect)(() => {
|
|
56003
56013
|
const continuousSet = messages?.find(
|
|
56004
56014
|
(message) => message.id === firstMessageId.current
|
|
56005
56015
|
);
|
|
@@ -56014,24 +56024,24 @@ var useMessageSetKey = ({
|
|
|
56014
56024
|
};
|
|
56015
56025
|
|
|
56016
56026
|
// src/components/MessageList/hooks/VirtualizedMessageList/useScrollToBottomOnNewMessage.ts
|
|
56017
|
-
var
|
|
56027
|
+
var import_react254 = require("react");
|
|
56018
56028
|
var useScrollToBottomOnNewMessage = ({
|
|
56019
56029
|
messages,
|
|
56020
56030
|
scrollToBottom,
|
|
56021
56031
|
scrollToLatestMessageOnFocus
|
|
56022
56032
|
}) => {
|
|
56023
|
-
const [newMessagesReceivedInBackground, setNewMessagesReceivedInBackground] = (0,
|
|
56024
|
-
const scrollToBottomIfConfigured = (0,
|
|
56033
|
+
const [newMessagesReceivedInBackground, setNewMessagesReceivedInBackground] = (0, import_react254.useState)(false);
|
|
56034
|
+
const scrollToBottomIfConfigured = (0, import_react254.useRef)(void 0);
|
|
56025
56035
|
scrollToBottomIfConfigured.current = (event) => {
|
|
56026
56036
|
if (!scrollToLatestMessageOnFocus || !newMessagesReceivedInBackground || event.target !== window) {
|
|
56027
56037
|
return;
|
|
56028
56038
|
}
|
|
56029
56039
|
setTimeout(scrollToBottom, 100);
|
|
56030
56040
|
};
|
|
56031
|
-
(0,
|
|
56041
|
+
(0, import_react254.useEffect)(() => {
|
|
56032
56042
|
setNewMessagesReceivedInBackground(true);
|
|
56033
56043
|
}, [messages]);
|
|
56034
|
-
(0,
|
|
56044
|
+
(0, import_react254.useEffect)(() => {
|
|
56035
56045
|
const handleFocus = (event) => {
|
|
56036
56046
|
scrollToBottomIfConfigured.current?.(event);
|
|
56037
56047
|
};
|
|
@@ -56050,14 +56060,14 @@ var useScrollToBottomOnNewMessage = ({
|
|
|
56050
56060
|
};
|
|
56051
56061
|
|
|
56052
56062
|
// src/components/MessageList/hooks/VirtualizedMessageList/useUnreadMessagesNotificationVirtualized.ts
|
|
56053
|
-
var
|
|
56063
|
+
var import_react255 = require("react");
|
|
56054
56064
|
var useUnreadMessagesNotificationVirtualized = ({
|
|
56055
56065
|
lastRead,
|
|
56056
56066
|
showAlways,
|
|
56057
56067
|
unreadCount
|
|
56058
56068
|
}) => {
|
|
56059
|
-
const [show, setShow] = (0,
|
|
56060
|
-
const toggleShowUnreadMessagesNotification = (0,
|
|
56069
|
+
const [show, setShow] = (0, import_react255.useState)(false);
|
|
56070
|
+
const toggleShowUnreadMessagesNotification = (0, import_react255.useCallback)(
|
|
56061
56071
|
(renderedMessages) => {
|
|
56062
56072
|
if (!unreadCount) return;
|
|
56063
56073
|
const firstRenderedMessage = renderedMessages[0];
|
|
@@ -56071,7 +56081,7 @@ var useUnreadMessagesNotificationVirtualized = ({
|
|
|
56071
56081
|
},
|
|
56072
56082
|
[lastRead, showAlways, unreadCount]
|
|
56073
56083
|
);
|
|
56074
|
-
(0,
|
|
56084
|
+
(0, import_react255.useEffect)(() => {
|
|
56075
56085
|
if (!unreadCount) setShow(false);
|
|
56076
56086
|
}, [unreadCount]);
|
|
56077
56087
|
return { show, toggleShowUnreadMessagesNotification };
|
|
@@ -56080,7 +56090,7 @@ var useUnreadMessagesNotificationVirtualized = ({
|
|
|
56080
56090
|
// src/components/MessageList/VirtualizedMessageListComponents.tsx
|
|
56081
56091
|
var import_clsx64 = __toESM(require("clsx"));
|
|
56082
56092
|
var import_lodash21 = __toESM(require("lodash.throttle"));
|
|
56083
|
-
var
|
|
56093
|
+
var import_react256 = __toESM(require("react"));
|
|
56084
56094
|
var PREPEND_OFFSET = 10 ** 7;
|
|
56085
56095
|
function calculateItemIndex(virtuosoIndex, numItemsPrepended) {
|
|
56086
56096
|
return virtuosoIndex + numItemsPrepended - PREPEND_OFFSET;
|
|
@@ -56101,10 +56111,10 @@ var Item3 = ({
|
|
|
56101
56111
|
context,
|
|
56102
56112
|
...props
|
|
56103
56113
|
}) => {
|
|
56104
|
-
if (!context) return /* @__PURE__ */
|
|
56114
|
+
if (!context) return /* @__PURE__ */ import_react256.default.createElement(import_react256.default.Fragment, null);
|
|
56105
56115
|
const message = context.processedMessages[calculateItemIndex(props["data-item-index"], context.numItemsPrepended)];
|
|
56106
56116
|
const groupStyles = context.messageGroupStyles[message.id];
|
|
56107
|
-
return /* @__PURE__ */
|
|
56117
|
+
return /* @__PURE__ */ import_react256.default.createElement(
|
|
56108
56118
|
"div",
|
|
56109
56119
|
{
|
|
56110
56120
|
...props,
|
|
@@ -56118,13 +56128,13 @@ var Header = ({
|
|
|
56118
56128
|
context
|
|
56119
56129
|
}) => {
|
|
56120
56130
|
const { LoadingIndicator: LoadingIndicator2 = LoadingIndicator } = useComponentContext("VirtualizedMessageListHeader");
|
|
56121
|
-
return /* @__PURE__ */
|
|
56131
|
+
return /* @__PURE__ */ import_react256.default.createElement(import_react256.default.Fragment, null, context?.head, context?.loadingMore && LoadingIndicator2 && /* @__PURE__ */ import_react256.default.createElement("div", { className: "str-chat__virtual-list__loading" }, /* @__PURE__ */ import_react256.default.createElement(LoadingIndicator2, { size: 20 })));
|
|
56122
56132
|
};
|
|
56123
56133
|
var EmptyPlaceholder = ({
|
|
56124
56134
|
context
|
|
56125
56135
|
}) => {
|
|
56126
56136
|
const { EmptyStateIndicator: EmptyStateIndicator2 = EmptyStateIndicator } = useComponentContext("VirtualizedMessageList");
|
|
56127
|
-
return /* @__PURE__ */
|
|
56137
|
+
return /* @__PURE__ */ import_react256.default.createElement(import_react256.default.Fragment, null, EmptyStateIndicator2 && /* @__PURE__ */ import_react256.default.createElement(EmptyStateIndicator2, { listType: context?.threadList ? "thread" : "message" }));
|
|
56128
56138
|
};
|
|
56129
56139
|
var messageRenderer = (virtuosoIndex, _data, virtuosoContext) => {
|
|
56130
56140
|
const {
|
|
@@ -56160,12 +56170,12 @@ var messageRenderer = (virtuosoIndex, _data, virtuosoContext) => {
|
|
|
56160
56170
|
return customMessageRenderer(messageList, streamMessageIndex);
|
|
56161
56171
|
}
|
|
56162
56172
|
const message = messageList[streamMessageIndex];
|
|
56163
|
-
if (!message) return /* @__PURE__ */
|
|
56173
|
+
if (!message) return /* @__PURE__ */ import_react256.default.createElement("div", { style: { height: "1px" } });
|
|
56164
56174
|
if (isDateSeparatorMessage(message)) {
|
|
56165
|
-
return DateSeparator2 ? /* @__PURE__ */
|
|
56175
|
+
return DateSeparator2 ? /* @__PURE__ */ import_react256.default.createElement(DateSeparator2, { date: message.date, unread: message.unread }) : null;
|
|
56166
56176
|
}
|
|
56167
56177
|
if (message.type === "system") {
|
|
56168
|
-
return MessageSystem ? /* @__PURE__ */
|
|
56178
|
+
return MessageSystem ? /* @__PURE__ */ import_react256.default.createElement(MessageSystem, { message }) : null;
|
|
56169
56179
|
}
|
|
56170
56180
|
const groupedByUser = shouldGroupByUser && streamMessageIndex > 0 && message.user?.id === messageList[streamMessageIndex - 1].user?.id;
|
|
56171
56181
|
const maybePrevMessage = messageList[streamMessageIndex - 1];
|
|
@@ -56181,7 +56191,7 @@ var messageRenderer = (virtuosoIndex, _data, virtuosoContext) => {
|
|
|
56181
56191
|
previousMessage: streamMessageIndex ? messageList[streamMessageIndex - 1] : void 0,
|
|
56182
56192
|
unreadMessageCount
|
|
56183
56193
|
});
|
|
56184
|
-
return /* @__PURE__ */
|
|
56194
|
+
return /* @__PURE__ */ import_react256.default.createElement(import_react256.default.Fragment, null, isFirstUnreadMessage && /* @__PURE__ */ import_react256.default.createElement("div", { className: "str-chat__unread-messages-separator-wrapper" }, /* @__PURE__ */ import_react256.default.createElement(UnreadMessagesSeparator2, { unreadCount: unreadMessageCount })), /* @__PURE__ */ import_react256.default.createElement(
|
|
56185
56195
|
Message,
|
|
56186
56196
|
{
|
|
56187
56197
|
additionalMessageInputProps,
|
|
@@ -56208,12 +56218,12 @@ var messageRenderer = (virtuosoIndex, _data, virtuosoContext) => {
|
|
|
56208
56218
|
};
|
|
56209
56219
|
|
|
56210
56220
|
// src/context/VirtualizedMessageListContext.tsx
|
|
56211
|
-
var
|
|
56212
|
-
var VirtualizedMessageListContext = (0,
|
|
56221
|
+
var import_react257 = __toESM(require("react"));
|
|
56222
|
+
var VirtualizedMessageListContext = (0, import_react257.createContext)(void 0);
|
|
56213
56223
|
var VirtualizedMessageListContextProvider = ({
|
|
56214
56224
|
children,
|
|
56215
56225
|
value
|
|
56216
|
-
}) => /* @__PURE__ */
|
|
56226
|
+
}) => /* @__PURE__ */ import_react257.default.createElement(
|
|
56217
56227
|
VirtualizedMessageListContext.Provider,
|
|
56218
56228
|
{
|
|
56219
56229
|
value
|
|
@@ -56228,7 +56238,7 @@ function captureResizeObserverExceededError(e2) {
|
|
|
56228
56238
|
}
|
|
56229
56239
|
}
|
|
56230
56240
|
function useCaptureResizeObserverExceededError() {
|
|
56231
|
-
(0,
|
|
56241
|
+
(0, import_react258.useEffect)(() => {
|
|
56232
56242
|
window.addEventListener("error", captureResizeObserverExceededError);
|
|
56233
56243
|
return () => {
|
|
56234
56244
|
window.removeEventListener("error", captureResizeObserverExceededError);
|
|
@@ -56314,15 +56324,15 @@ var VirtualizedMessageListWithContext = (props) => {
|
|
|
56314
56324
|
const { client, customClasses } = useChatContext(
|
|
56315
56325
|
"VirtualizedMessageList"
|
|
56316
56326
|
);
|
|
56317
|
-
const virtuoso = (0,
|
|
56318
|
-
const lastRead = (0,
|
|
56327
|
+
const virtuoso = (0, import_react258.useRef)(null);
|
|
56328
|
+
const lastRead = (0, import_react258.useMemo)(() => channel.lastRead?.(), [channel]);
|
|
56319
56329
|
const { show: showUnreadMessagesNotification, toggleShowUnreadMessagesNotification } = useUnreadMessagesNotificationVirtualized({
|
|
56320
56330
|
lastRead: channelUnreadUiState?.last_read,
|
|
56321
56331
|
showAlways: !!showUnreadNotificationAlways,
|
|
56322
56332
|
unreadCount: channelUnreadUiState?.unread_messages ?? 0
|
|
56323
56333
|
});
|
|
56324
56334
|
const { giphyPreviewMessage, setGiphyPreviewMessage } = useGiphyPreview(separateGiphyPreview);
|
|
56325
|
-
const processedMessages = (0,
|
|
56335
|
+
const processedMessages = (0, import_react258.useMemo)(() => {
|
|
56326
56336
|
if (typeof messages === "undefined") {
|
|
56327
56337
|
return [];
|
|
56328
56338
|
}
|
|
@@ -56354,12 +56364,12 @@ var VirtualizedMessageListWithContext = (props) => {
|
|
|
56354
56364
|
returnAllReadData,
|
|
56355
56365
|
userID: client.userID
|
|
56356
56366
|
});
|
|
56357
|
-
const lastReceivedMessageId = (0,
|
|
56367
|
+
const lastReceivedMessageId = (0, import_react258.useMemo)(
|
|
56358
56368
|
() => getLastReceived(processedMessages),
|
|
56359
56369
|
[processedMessages]
|
|
56360
56370
|
);
|
|
56361
56371
|
const groupStylesFn = groupStyles || getGroupStyles;
|
|
56362
|
-
const messageGroupStyles = (0,
|
|
56372
|
+
const messageGroupStyles = (0, import_react258.useMemo)(
|
|
56363
56373
|
() => processedMessages.reduce((acc, message, i) => {
|
|
56364
56374
|
const style = groupStylesFn(
|
|
56365
56375
|
message,
|
|
@@ -56392,7 +56402,7 @@ var VirtualizedMessageListWithContext = (props) => {
|
|
|
56392
56402
|
messageListIsThread: !!threadList,
|
|
56393
56403
|
wasMarkedUnread: !!channelUnreadUiState?.first_unread_message_id
|
|
56394
56404
|
});
|
|
56395
|
-
const scrollToBottom = (0,
|
|
56405
|
+
const scrollToBottom = (0, import_react258.useCallback)(async () => {
|
|
56396
56406
|
if (hasMoreNewer) {
|
|
56397
56407
|
await jumpToLatestMessage();
|
|
56398
56408
|
return;
|
|
@@ -56424,7 +56434,7 @@ var VirtualizedMessageListWithContext = (props) => {
|
|
|
56424
56434
|
processedMessages,
|
|
56425
56435
|
client.userID
|
|
56426
56436
|
);
|
|
56427
|
-
const handleItemsRendered = (0,
|
|
56437
|
+
const handleItemsRendered = (0, import_react258.useMemo)(
|
|
56428
56438
|
() => makeItemsRenderedHandler([toggleShowUnreadMessagesNotification], processedMessages),
|
|
56429
56439
|
[processedMessages, toggleShowUnreadMessagesNotification]
|
|
56430
56440
|
);
|
|
@@ -56437,7 +56447,7 @@ var VirtualizedMessageListWithContext = (props) => {
|
|
|
56437
56447
|
}
|
|
56438
56448
|
return isAtBottom ? stickToBottomScrollBehavior : false;
|
|
56439
56449
|
};
|
|
56440
|
-
const computeItemKey2 = (0,
|
|
56450
|
+
const computeItemKey2 = (0, import_react258.useCallback)(
|
|
56441
56451
|
(index3, _, { numItemsPrepended: numItemsPrepended2, processedMessages: processedMessages2 }) => processedMessages2[calculateItemIndex(index3, numItemsPrepended2)].id,
|
|
56442
56452
|
[]
|
|
56443
56453
|
);
|
|
@@ -56454,7 +56464,7 @@ var VirtualizedMessageListWithContext = (props) => {
|
|
|
56454
56464
|
loadMore?.(messageLimit);
|
|
56455
56465
|
}
|
|
56456
56466
|
};
|
|
56457
|
-
(0,
|
|
56467
|
+
(0, import_react258.useEffect)(() => {
|
|
56458
56468
|
let scrollTimeout;
|
|
56459
56469
|
if (highlightedMessageId) {
|
|
56460
56470
|
const index3 = findMessageIndex(processedMessages, highlightedMessageId);
|
|
@@ -56468,19 +56478,20 @@ var VirtualizedMessageListWithContext = (props) => {
|
|
|
56468
56478
|
clearTimeout(scrollTimeout);
|
|
56469
56479
|
};
|
|
56470
56480
|
}, [highlightedMessageId, processedMessages]);
|
|
56481
|
+
const id = useStableId();
|
|
56471
56482
|
if (!processedMessages) return null;
|
|
56472
|
-
const dialogManagerId = threadList ?
|
|
56473
|
-
return /* @__PURE__ */
|
|
56483
|
+
const dialogManagerId = threadList ? `virtualized-message-list-dialog-manager-thread-${id}` : `virtualized-message-list-dialog-manager-${id}`;
|
|
56484
|
+
return /* @__PURE__ */ import_react258.default.createElement(VirtualizedMessageListContextProvider, { value: { scrollToBottom } }, /* @__PURE__ */ import_react258.default.createElement(MessageListMainPanel2, null, /* @__PURE__ */ import_react258.default.createElement(DialogManagerProvider, { id: dialogManagerId }, !threadList && showUnreadMessagesNotification && /* @__PURE__ */ import_react258.default.createElement(
|
|
56474
56485
|
UnreadMessagesNotification2,
|
|
56475
56486
|
{
|
|
56476
56487
|
unreadCount: channelUnreadUiState?.unread_messages
|
|
56477
56488
|
}
|
|
56478
|
-
), /* @__PURE__ */
|
|
56489
|
+
), /* @__PURE__ */ import_react258.default.createElement(
|
|
56479
56490
|
"div",
|
|
56480
56491
|
{
|
|
56481
56492
|
className: customClasses?.virtualizedMessageList || "str-chat__virtual-list"
|
|
56482
56493
|
},
|
|
56483
|
-
/* @__PURE__ */
|
|
56494
|
+
/* @__PURE__ */ import_react258.default.createElement(
|
|
56484
56495
|
import_react_virtuoso2.Virtuoso,
|
|
56485
56496
|
{
|
|
56486
56497
|
atBottomStateChange,
|
|
@@ -56546,7 +56557,7 @@ var VirtualizedMessageListWithContext = (props) => {
|
|
|
56546
56557
|
...defaultItemHeight ? { defaultItemHeight } : {}
|
|
56547
56558
|
}
|
|
56548
56559
|
)
|
|
56549
|
-
)), TypingIndicator2 && /* @__PURE__ */
|
|
56560
|
+
)), TypingIndicator2 && /* @__PURE__ */ import_react258.default.createElement(TypingIndicator2, null)), /* @__PURE__ */ import_react258.default.createElement(
|
|
56550
56561
|
MessageListNotifications2,
|
|
56551
56562
|
{
|
|
56552
56563
|
hasNewMessages: newMessagesNotification,
|
|
@@ -56558,7 +56569,7 @@ var VirtualizedMessageListWithContext = (props) => {
|
|
|
56558
56569
|
threadList,
|
|
56559
56570
|
unreadCount: threadList ? void 0 : channelUnreadUiState?.unread_messages
|
|
56560
56571
|
}
|
|
56561
|
-
), giphyPreviewMessage && /* @__PURE__ */
|
|
56572
|
+
), giphyPreviewMessage && /* @__PURE__ */ import_react258.default.createElement(GiphyPreviewMessage2, { message: giphyPreviewMessage }));
|
|
56562
56573
|
};
|
|
56563
56574
|
function VirtualizedMessageList(props) {
|
|
56564
56575
|
const { jumpToLatestMessage, loadMore, loadMoreNewer } = useChannelActionContext("VirtualizedMessageList");
|
|
@@ -56576,7 +56587,7 @@ function VirtualizedMessageList(props) {
|
|
|
56576
56587
|
suppressAutoscroll
|
|
56577
56588
|
} = useChannelStateContext("VirtualizedMessageList");
|
|
56578
56589
|
const messages = props.messages || contextMessages;
|
|
56579
|
-
return /* @__PURE__ */
|
|
56590
|
+
return /* @__PURE__ */ import_react258.default.createElement(
|
|
56580
56591
|
VirtualizedMessageListWithContext,
|
|
56581
56592
|
{
|
|
56582
56593
|
channel,
|
|
@@ -56617,12 +56628,12 @@ var useChannelContainerClasses = ({
|
|
|
56617
56628
|
};
|
|
56618
56629
|
|
|
56619
56630
|
// src/components/Channel/utils.ts
|
|
56620
|
-
var
|
|
56631
|
+
var import_nanoid11 = require("nanoid");
|
|
56621
56632
|
var makeAddNotifications = (setNotifications, notificationTimeouts) => (text7, type) => {
|
|
56622
56633
|
if (typeof text7 !== "string" || type !== "success" && type !== "error") {
|
|
56623
56634
|
return;
|
|
56624
56635
|
}
|
|
56625
|
-
const id = (0,
|
|
56636
|
+
const id = (0, import_nanoid11.nanoid)();
|
|
56626
56637
|
setNotifications((prevNotifications) => [...prevNotifications, { id, text: text7, type }]);
|
|
56627
56638
|
const timeout = setTimeout(
|
|
56628
56639
|
() => setNotifications(
|
|
@@ -56782,7 +56793,7 @@ var ChannelContainer = ({
|
|
|
56782
56793
|
customClasses
|
|
56783
56794
|
});
|
|
56784
56795
|
const className = (0, import_clsx65.default)(chatClass, theme, channelClass, additionalClassName);
|
|
56785
|
-
return /* @__PURE__ */
|
|
56796
|
+
return /* @__PURE__ */ import_react259.default.createElement("div", { id: CHANNEL_CONTAINER_ID, ...props, className }, children);
|
|
56786
56797
|
};
|
|
56787
56798
|
var UnMemoizedChannel = (props) => {
|
|
56788
56799
|
const {
|
|
@@ -56794,15 +56805,15 @@ var UnMemoizedChannel = (props) => {
|
|
|
56794
56805
|
const { channel: contextChannel, channelsQueryState } = useChatContext("Channel");
|
|
56795
56806
|
const channel = propsChannel || contextChannel;
|
|
56796
56807
|
if (channelsQueryState.queryInProgress === "reload" && LoadingIndicator2) {
|
|
56797
|
-
return /* @__PURE__ */
|
|
56808
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react259.default.createElement(LoadingIndicator2, null));
|
|
56798
56809
|
}
|
|
56799
56810
|
if (channelsQueryState.error && LoadingErrorIndicator2) {
|
|
56800
|
-
return /* @__PURE__ */
|
|
56811
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react259.default.createElement(LoadingErrorIndicator2, { error: channelsQueryState.error }));
|
|
56801
56812
|
}
|
|
56802
56813
|
if (!channel?.cid) {
|
|
56803
|
-
return /* @__PURE__ */
|
|
56814
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, EmptyPlaceholder2);
|
|
56804
56815
|
}
|
|
56805
|
-
return /* @__PURE__ */
|
|
56816
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelInner, { ...props, channel, key: channel.cid });
|
|
56806
56817
|
};
|
|
56807
56818
|
var ChannelInner = (props) => {
|
|
56808
56819
|
const {
|
|
@@ -56828,7 +56839,7 @@ var ChannelInner = (props) => {
|
|
|
56828
56839
|
optionalMessageInputProps = {},
|
|
56829
56840
|
skipMessageDataMemoization
|
|
56830
56841
|
} = props;
|
|
56831
|
-
const channelQueryOptions = (0,
|
|
56842
|
+
const channelQueryOptions = (0, import_react259.useMemo)(
|
|
56832
56843
|
() => (0, import_lodash23.default)(propChannelQueryOptions, {
|
|
56833
56844
|
messages: { limit: DEFAULT_INITIAL_CHANNEL_PAGE_SIZE }
|
|
56834
56845
|
}),
|
|
@@ -56839,13 +56850,13 @@ var ChannelInner = (props) => {
|
|
|
56839
56850
|
const chatContainerClass = getChatContainerClass(customClasses?.chatContainer);
|
|
56840
56851
|
const windowsEmojiClass = useImageFlagEmojisOnWindowsClass();
|
|
56841
56852
|
const thread = useThreadContext();
|
|
56842
|
-
const [channelConfig, setChannelConfig] = (0,
|
|
56843
|
-
const [notifications, setNotifications] = (0,
|
|
56844
|
-
const [quotedMessage, setQuotedMessage] = (0,
|
|
56845
|
-
const [channelUnreadUiState, _setChannelUnreadUiState] = (0,
|
|
56846
|
-
const notificationTimeouts = (0,
|
|
56847
|
-
const channelReducer = (0,
|
|
56848
|
-
const [state, dispatch] = (0,
|
|
56853
|
+
const [channelConfig, setChannelConfig] = (0, import_react259.useState)(channel.getConfig());
|
|
56854
|
+
const [notifications, setNotifications] = (0, import_react259.useState)([]);
|
|
56855
|
+
const [quotedMessage, setQuotedMessage] = (0, import_react259.useState)();
|
|
56856
|
+
const [channelUnreadUiState, _setChannelUnreadUiState] = (0, import_react259.useState)();
|
|
56857
|
+
const notificationTimeouts = (0, import_react259.useRef)([]);
|
|
56858
|
+
const channelReducer = (0, import_react259.useMemo)(() => makeChannelReducer(), []);
|
|
56859
|
+
const [state, dispatch] = (0, import_react259.useReducer)(
|
|
56849
56860
|
channelReducer,
|
|
56850
56861
|
// channel.initialized === false if client.channel().query() was not called, e.g. ChannelList is not used
|
|
56851
56862
|
// => Channel will call channel.watch() in useLayoutEffect => state.loading is used to signal the watch() call state
|
|
@@ -56857,10 +56868,10 @@ var ChannelInner = (props) => {
|
|
|
56857
56868
|
);
|
|
56858
56869
|
const jumpToMessageFromSearch = useSearchFocusedMessage();
|
|
56859
56870
|
const isMounted = useIsMounted();
|
|
56860
|
-
const originalTitle = (0,
|
|
56861
|
-
const lastRead = (0,
|
|
56862
|
-
const online = (0,
|
|
56863
|
-
const clearHighlightedMessageTimeoutId = (0,
|
|
56871
|
+
const originalTitle = (0, import_react259.useRef)("");
|
|
56872
|
+
const lastRead = (0, import_react259.useRef)(void 0);
|
|
56873
|
+
const online = (0, import_react259.useRef)(true);
|
|
56874
|
+
const clearHighlightedMessageTimeoutId = (0, import_react259.useRef)(
|
|
56864
56875
|
null
|
|
56865
56876
|
);
|
|
56866
56877
|
const channelCapabilitiesArray = channel.data?.own_capabilities;
|
|
@@ -56872,14 +56883,14 @@ var ChannelInner = (props) => {
|
|
|
56872
56883
|
trailing: true
|
|
56873
56884
|
}
|
|
56874
56885
|
);
|
|
56875
|
-
const setChannelUnreadUiState = (0,
|
|
56886
|
+
const setChannelUnreadUiState = (0, import_react259.useMemo)(
|
|
56876
56887
|
() => (0, import_lodash24.default)(_setChannelUnreadUiState, 200, {
|
|
56877
56888
|
leading: true,
|
|
56878
56889
|
trailing: false
|
|
56879
56890
|
}),
|
|
56880
56891
|
[]
|
|
56881
56892
|
);
|
|
56882
|
-
const markRead = (0,
|
|
56893
|
+
const markRead = (0, import_react259.useMemo)(
|
|
56883
56894
|
() => (0, import_lodash24.default)(
|
|
56884
56895
|
async (options) => {
|
|
56885
56896
|
const { updateChannelUiUnreadState = true } = options ?? {};
|
|
@@ -56982,7 +56993,7 @@ var ChannelInner = (props) => {
|
|
|
56982
56993
|
}
|
|
56983
56994
|
throttledCopyStateFromChannel();
|
|
56984
56995
|
};
|
|
56985
|
-
(0,
|
|
56996
|
+
(0, import_react259.useLayoutEffect)(() => {
|
|
56986
56997
|
let errored = false;
|
|
56987
56998
|
let done = false;
|
|
56988
56999
|
(async () => {
|
|
@@ -57048,12 +57059,12 @@ var ChannelInner = (props) => {
|
|
|
57048
57059
|
channelConfig?.read_events,
|
|
57049
57060
|
initializeOnMount
|
|
57050
57061
|
]);
|
|
57051
|
-
(0,
|
|
57062
|
+
(0, import_react259.useEffect)(() => {
|
|
57052
57063
|
if (!state.thread) return;
|
|
57053
57064
|
const message = state.messages?.find((m) => m.id === state.thread?.id);
|
|
57054
57065
|
if (message) dispatch({ message, type: "setThread" });
|
|
57055
57066
|
}, [state.messages, state.thread]);
|
|
57056
|
-
const handleHighlightedMessageChange = (0,
|
|
57067
|
+
const handleHighlightedMessageChange = (0, import_react259.useCallback)(
|
|
57057
57068
|
({
|
|
57058
57069
|
highlightDuration,
|
|
57059
57070
|
highlightedMessageId
|
|
@@ -57076,15 +57087,15 @@ var ChannelInner = (props) => {
|
|
|
57076
57087
|
},
|
|
57077
57088
|
[channel, searchController]
|
|
57078
57089
|
);
|
|
57079
|
-
(0,
|
|
57090
|
+
(0, import_react259.useEffect)(() => {
|
|
57080
57091
|
if (!jumpToMessageFromSearch?.id) return;
|
|
57081
57092
|
handleHighlightedMessageChange({ highlightedMessageId: jumpToMessageFromSearch.id });
|
|
57082
57093
|
}, [jumpToMessageFromSearch, handleHighlightedMessageChange]);
|
|
57083
|
-
const addNotification = (0,
|
|
57094
|
+
const addNotification = (0, import_react259.useMemo)(
|
|
57084
57095
|
() => makeAddNotifications(setNotifications, notificationTimeouts.current),
|
|
57085
57096
|
[]
|
|
57086
57097
|
);
|
|
57087
|
-
const loadMoreFinished = (0,
|
|
57098
|
+
const loadMoreFinished = (0, import_react259.useCallback)(
|
|
57088
57099
|
(0, import_lodash22.default)(
|
|
57089
57100
|
(hasMore, messages) => {
|
|
57090
57101
|
if (!isMounted.current) return;
|
|
@@ -57145,7 +57156,7 @@ var ChannelInner = (props) => {
|
|
|
57145
57156
|
});
|
|
57146
57157
|
return queryResponse.messages.length;
|
|
57147
57158
|
};
|
|
57148
|
-
const jumpToMessage = (0,
|
|
57159
|
+
const jumpToMessage = (0, import_react259.useCallback)(
|
|
57149
57160
|
async (messageId, messageLimit = DEFAULT_JUMP_TO_PAGE_SIZE, highlightDuration = DEFAULT_HIGHLIGHT_DURATION) => {
|
|
57150
57161
|
dispatch({ loadingMore: true, type: "setLoadingMore" });
|
|
57151
57162
|
await channel.state.loadMessageIntoState(messageId, void 0, messageLimit);
|
|
@@ -57157,14 +57168,14 @@ var ChannelInner = (props) => {
|
|
|
57157
57168
|
},
|
|
57158
57169
|
[channel, handleHighlightedMessageChange, loadMoreFinished]
|
|
57159
57170
|
);
|
|
57160
|
-
const jumpToLatestMessage = (0,
|
|
57171
|
+
const jumpToLatestMessage = (0, import_react259.useCallback)(async () => {
|
|
57161
57172
|
await channel.state.loadMessageIntoState("latest");
|
|
57162
57173
|
loadMoreFinished(channel.state.messagePagination.hasPrev, channel.state.messages);
|
|
57163
57174
|
dispatch({
|
|
57164
57175
|
type: "jumpToLatestMessage"
|
|
57165
57176
|
});
|
|
57166
57177
|
}, [channel, loadMoreFinished]);
|
|
57167
|
-
const jumpToFirstUnreadMessage = (0,
|
|
57178
|
+
const jumpToFirstUnreadMessage = (0, import_react259.useCallback)(
|
|
57168
57179
|
async (queryMessageLimit = DEFAULT_JUMP_TO_PAGE_SIZE, highlightDuration = DEFAULT_HIGHLIGHT_DURATION) => {
|
|
57169
57180
|
if (!channelUnreadUiState?.unread_messages) return;
|
|
57170
57181
|
let lastReadMessageId = channelUnreadUiState?.last_read_message_id;
|
|
@@ -57287,7 +57298,7 @@ var ChannelInner = (props) => {
|
|
|
57287
57298
|
channelUnreadUiState
|
|
57288
57299
|
]
|
|
57289
57300
|
);
|
|
57290
|
-
const deleteMessage = (0,
|
|
57301
|
+
const deleteMessage = (0, import_react259.useCallback)(
|
|
57291
57302
|
async (message) => {
|
|
57292
57303
|
if (!message?.id) {
|
|
57293
57304
|
throw new Error("Cannot delete a message - missing message ID.");
|
|
@@ -57392,7 +57403,7 @@ var ChannelInner = (props) => {
|
|
|
57392
57403
|
attachments,
|
|
57393
57404
|
created_at: /* @__PURE__ */ new Date(),
|
|
57394
57405
|
html: text7,
|
|
57395
|
-
id: customMessageData?.id ?? `${client.userID}-${(0,
|
|
57406
|
+
id: customMessageData?.id ?? `${client.userID}-${(0, import_nanoid12.nanoid)()}`,
|
|
57396
57407
|
mentioned_users,
|
|
57397
57408
|
parent_id: parent?.id,
|
|
57398
57409
|
reactions: [],
|
|
@@ -57444,7 +57455,7 @@ var ChannelInner = (props) => {
|
|
|
57444
57455
|
event?.preventDefault();
|
|
57445
57456
|
dispatch({ type: "closeThread" });
|
|
57446
57457
|
};
|
|
57447
|
-
const loadMoreThreadFinished = (0,
|
|
57458
|
+
const loadMoreThreadFinished = (0, import_react259.useCallback)(
|
|
57448
57459
|
(0, import_lodash22.default)(
|
|
57449
57460
|
(threadHasMore, threadMessages) => {
|
|
57450
57461
|
dispatch({
|
|
@@ -57508,7 +57519,7 @@ var ChannelInner = (props) => {
|
|
|
57508
57519
|
videoAttachmentSizeHandler: props.videoAttachmentSizeHandler || getVideoAttachmentConfiguration,
|
|
57509
57520
|
watcher_count: state.watcherCount
|
|
57510
57521
|
});
|
|
57511
|
-
const channelActionContextValue = (0,
|
|
57522
|
+
const channelActionContextValue = (0, import_react259.useMemo)(
|
|
57512
57523
|
() => ({
|
|
57513
57524
|
addNotification,
|
|
57514
57525
|
closeThread,
|
|
@@ -57549,7 +57560,7 @@ var ChannelInner = (props) => {
|
|
|
57549
57560
|
setChannelUnreadUiState
|
|
57550
57561
|
]
|
|
57551
57562
|
);
|
|
57552
|
-
const componentContextValue = (0,
|
|
57563
|
+
const componentContextValue = (0, import_react259.useMemo)(
|
|
57553
57564
|
() => ({
|
|
57554
57565
|
Attachment: props.Attachment,
|
|
57555
57566
|
AttachmentPreviewList: props.AttachmentPreviewList,
|
|
@@ -57681,26 +57692,26 @@ var ChannelInner = (props) => {
|
|
|
57681
57692
|
typing
|
|
57682
57693
|
});
|
|
57683
57694
|
if (state.error) {
|
|
57684
|
-
return /* @__PURE__ */
|
|
57695
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react259.default.createElement(LoadingErrorIndicator2, { error: state.error }));
|
|
57685
57696
|
}
|
|
57686
57697
|
if (state.loading) {
|
|
57687
|
-
return /* @__PURE__ */
|
|
57698
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react259.default.createElement(LoadingIndicator2, null));
|
|
57688
57699
|
}
|
|
57689
57700
|
if (!channel.watch) {
|
|
57690
|
-
return /* @__PURE__ */
|
|
57701
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, null, /* @__PURE__ */ import_react259.default.createElement("div", null, t2("Channel Missing")));
|
|
57691
57702
|
}
|
|
57692
|
-
return /* @__PURE__ */
|
|
57703
|
+
return /* @__PURE__ */ import_react259.default.createElement(ChannelContainer, { className: windowsEmojiClass }, /* @__PURE__ */ import_react259.default.createElement(ChannelStateProvider, { value: channelStateContextValue }, /* @__PURE__ */ import_react259.default.createElement(ChannelActionProvider, { value: channelActionContextValue }, /* @__PURE__ */ import_react259.default.createElement(WithComponents, { overrides: componentContextValue }, /* @__PURE__ */ import_react259.default.createElement(TypingProvider, { value: typingContextValue }, /* @__PURE__ */ import_react259.default.createElement("div", { className: `${chatContainerClass}` }, dragAndDropWindow && /* @__PURE__ */ import_react259.default.createElement(DropzoneProvider, { ...optionalMessageInputProps }, children), !dragAndDropWindow && /* @__PURE__ */ import_react259.default.createElement(import_react259.default.Fragment, null, children)))))));
|
|
57693
57704
|
};
|
|
57694
|
-
var Channel =
|
|
57705
|
+
var Channel = import_react259.default.memo(UnMemoizedChannel);
|
|
57695
57706
|
|
|
57696
57707
|
// src/components/ChannelHeader/ChannelHeader.tsx
|
|
57697
|
-
var
|
|
57708
|
+
var import_react261 = __toESM(require("react"));
|
|
57698
57709
|
|
|
57699
57710
|
// src/components/ChannelHeader/icons.tsx
|
|
57700
|
-
var
|
|
57711
|
+
var import_react260 = __toESM(require("react"));
|
|
57701
57712
|
var MenuIcon2 = ({ title }) => {
|
|
57702
57713
|
const { t: t2 } = useTranslationContext("MenuIcon");
|
|
57703
|
-
return /* @__PURE__ */
|
|
57714
|
+
return /* @__PURE__ */ import_react260.default.createElement("svg", { "data-testid": "menu-icon", viewBox: "0 0 448 512", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react260.default.createElement("title", null, title ?? t2("Menu")), /* @__PURE__ */ import_react260.default.createElement(
|
|
57704
57715
|
"path",
|
|
57705
57716
|
{
|
|
57706
57717
|
d: "M0 88C0 74.75 10.75 64 24 64H424C437.3 64 448 74.75 448 88C448 101.3 437.3 112 424 112H24C10.75 112 0 101.3 0 88zM0 248C0 234.7 10.75 224 24 224H424C437.3 224 448 234.7 448 248C448 261.3 437.3 272 424 272H24C10.75 272 0 261.3 0 248zM424 432H24C10.75 432 0 421.3 0 408C0 394.7 10.75 384 24 384H424C437.3 384 448 394.7 448 408C448 421.3 437.3 432 424 432z",
|
|
@@ -57727,15 +57738,15 @@ var ChannelHeader = (props) => {
|
|
|
57727
57738
|
overrideTitle
|
|
57728
57739
|
});
|
|
57729
57740
|
const { member_count, subtitle } = channel?.data || {};
|
|
57730
|
-
return /* @__PURE__ */
|
|
57741
|
+
return /* @__PURE__ */ import_react261.default.createElement("div", { className: "str-chat__channel-header" }, /* @__PURE__ */ import_react261.default.createElement(
|
|
57731
57742
|
"button",
|
|
57732
57743
|
{
|
|
57733
57744
|
"aria-label": t2("aria/Menu"),
|
|
57734
57745
|
className: "str-chat__header-hamburger",
|
|
57735
57746
|
onClick: openMobileNav
|
|
57736
57747
|
},
|
|
57737
|
-
/* @__PURE__ */
|
|
57738
|
-
), /* @__PURE__ */
|
|
57748
|
+
/* @__PURE__ */ import_react261.default.createElement(MenuIcon3, null)
|
|
57749
|
+
), /* @__PURE__ */ import_react261.default.createElement(
|
|
57739
57750
|
Avatar2,
|
|
57740
57751
|
{
|
|
57741
57752
|
className: "str-chat__avatar--channel-header",
|
|
@@ -57743,36 +57754,36 @@ var ChannelHeader = (props) => {
|
|
|
57743
57754
|
image: displayImage,
|
|
57744
57755
|
name: displayTitle
|
|
57745
57756
|
}
|
|
57746
|
-
), /* @__PURE__ */
|
|
57757
|
+
), /* @__PURE__ */ import_react261.default.createElement("div", { className: "str-chat__channel-header-end" }, /* @__PURE__ */ import_react261.default.createElement("p", { className: "str-chat__channel-header-title" }, displayTitle, " ", live && /* @__PURE__ */ import_react261.default.createElement("span", { className: "str-chat__header-livestream-livelabel" }, t2("live"))), subtitle && /* @__PURE__ */ import_react261.default.createElement("p", { className: "str-chat__channel-header-subtitle" }, subtitle), /* @__PURE__ */ import_react261.default.createElement("p", { className: "str-chat__channel-header-info" }, !live && !!member_count && member_count > 0 && /* @__PURE__ */ import_react261.default.createElement(import_react261.default.Fragment, null, t2("{{ memberCount }} members", {
|
|
57747
57758
|
memberCount: member_count
|
|
57748
57759
|
}), ",", " "), t2("{{ watcherCount }} online", { watcherCount: watcher_count }))));
|
|
57749
57760
|
};
|
|
57750
57761
|
|
|
57751
57762
|
// src/components/Chat/Chat.tsx
|
|
57752
|
-
var
|
|
57763
|
+
var import_react265 = __toESM(require("react"));
|
|
57753
57764
|
var import_stream_chat6 = require("stream-chat");
|
|
57754
57765
|
|
|
57755
57766
|
// src/components/Chat/hooks/useChat.ts
|
|
57756
|
-
var
|
|
57767
|
+
var import_react262 = require("react");
|
|
57757
57768
|
var useChat = ({
|
|
57758
57769
|
client,
|
|
57759
57770
|
defaultLanguage = "en",
|
|
57760
57771
|
i18nInstance,
|
|
57761
57772
|
initialNavOpen
|
|
57762
57773
|
}) => {
|
|
57763
|
-
const [translators, setTranslators] = (0,
|
|
57774
|
+
const [translators, setTranslators] = (0, import_react262.useState)({
|
|
57764
57775
|
t: (key) => key,
|
|
57765
57776
|
tDateTimeParser: defaultDateTimeParser,
|
|
57766
57777
|
userLanguage: "en"
|
|
57767
57778
|
});
|
|
57768
|
-
const [channel, setChannel] = (0,
|
|
57769
|
-
const [mutes, setMutes] = (0,
|
|
57770
|
-
const [navOpen, setNavOpen] = (0,
|
|
57771
|
-
const [latestMessageDatesByChannels, setLatestMessageDatesByChannels] = (0,
|
|
57779
|
+
const [channel, setChannel] = (0, import_react262.useState)();
|
|
57780
|
+
const [mutes, setMutes] = (0, import_react262.useState)([]);
|
|
57781
|
+
const [navOpen, setNavOpen] = (0, import_react262.useState)(initialNavOpen);
|
|
57782
|
+
const [latestMessageDatesByChannels, setLatestMessageDatesByChannels] = (0, import_react262.useState)({});
|
|
57772
57783
|
const clientMutes = client.user?.mutes || [];
|
|
57773
57784
|
const closeMobileNav = () => setNavOpen(false);
|
|
57774
57785
|
const openMobileNav = () => setTimeout(() => setNavOpen(true), 100);
|
|
57775
|
-
const appSettings = (0,
|
|
57786
|
+
const appSettings = (0, import_react262.useRef)(
|
|
57776
57787
|
null
|
|
57777
57788
|
);
|
|
57778
57789
|
const getAppSettings = () => {
|
|
@@ -57782,9 +57793,9 @@ var useChat = ({
|
|
|
57782
57793
|
appSettings.current = client.getAppSettings();
|
|
57783
57794
|
return appSettings.current;
|
|
57784
57795
|
};
|
|
57785
|
-
(0,
|
|
57796
|
+
(0, import_react262.useEffect)(() => {
|
|
57786
57797
|
if (!client) return;
|
|
57787
|
-
const version = "12.15.
|
|
57798
|
+
const version = "12.15.3";
|
|
57788
57799
|
const userAgent = client.getUserAgent();
|
|
57789
57800
|
if (!userAgent.includes("stream-chat-react")) {
|
|
57790
57801
|
client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);
|
|
@@ -57796,7 +57807,7 @@ var useChat = ({
|
|
|
57796
57807
|
client.polls.unregisterSubscriptions();
|
|
57797
57808
|
};
|
|
57798
57809
|
}, [client]);
|
|
57799
|
-
(0,
|
|
57810
|
+
(0, import_react262.useEffect)(() => {
|
|
57800
57811
|
setMutes(clientMutes);
|
|
57801
57812
|
const handleEvent = (event) => {
|
|
57802
57813
|
setMutes(event.me?.mutes || []);
|
|
@@ -57804,7 +57815,7 @@ var useChat = ({
|
|
|
57804
57815
|
client.on("notification.mutes_updated", handleEvent);
|
|
57805
57816
|
return () => client.off("notification.mutes_updated", handleEvent);
|
|
57806
57817
|
}, [clientMutes?.length]);
|
|
57807
|
-
(0,
|
|
57818
|
+
(0, import_react262.useEffect)(() => {
|
|
57808
57819
|
let userLanguage = client.user?.language;
|
|
57809
57820
|
if (!userLanguage) {
|
|
57810
57821
|
const browserLanguage = window.navigator.language.slice(0, 2);
|
|
@@ -57821,7 +57832,7 @@ var useChat = ({
|
|
|
57821
57832
|
});
|
|
57822
57833
|
});
|
|
57823
57834
|
}, [i18nInstance]);
|
|
57824
|
-
const setActiveChannel = (0,
|
|
57835
|
+
const setActiveChannel = (0, import_react262.useCallback)(
|
|
57825
57836
|
async (activeChannel, watchers = {}, event) => {
|
|
57826
57837
|
if (event && event.preventDefault) event.preventDefault();
|
|
57827
57838
|
if (activeChannel && Object.keys(watchers).length) {
|
|
@@ -57832,7 +57843,7 @@ var useChat = ({
|
|
|
57832
57843
|
},
|
|
57833
57844
|
[]
|
|
57834
57845
|
);
|
|
57835
|
-
(0,
|
|
57846
|
+
(0, import_react262.useEffect)(() => {
|
|
57836
57847
|
setLatestMessageDatesByChannels({});
|
|
57837
57848
|
}, [client.user?.id]);
|
|
57838
57849
|
return {
|
|
@@ -57849,7 +57860,7 @@ var useChat = ({
|
|
|
57849
57860
|
};
|
|
57850
57861
|
|
|
57851
57862
|
// src/components/Chat/hooks/useCreateChatContext.ts
|
|
57852
|
-
var
|
|
57863
|
+
var import_react263 = require("react");
|
|
57853
57864
|
var useCreateChatContext = (value) => {
|
|
57854
57865
|
const {
|
|
57855
57866
|
channel,
|
|
@@ -57874,7 +57885,7 @@ var useCreateChatContext = (value) => {
|
|
|
57874
57885
|
const clientValues = `${client.clientID}${Object.keys(client.activeChannels).length}${Object.keys(client.listeners).length}${client.mutedChannels.length}
|
|
57875
57886
|
${client.user?.id}`;
|
|
57876
57887
|
const mutedUsersLength = mutes.length;
|
|
57877
|
-
const chatContext = (0,
|
|
57888
|
+
const chatContext = (0, import_react263.useMemo)(
|
|
57878
57889
|
() => ({
|
|
57879
57890
|
channel,
|
|
57880
57891
|
channelsQueryState,
|
|
@@ -57909,10 +57920,10 @@ var useCreateChatContext = (value) => {
|
|
|
57909
57920
|
};
|
|
57910
57921
|
|
|
57911
57922
|
// src/components/Chat/hooks/useChannelsQueryState.ts
|
|
57912
|
-
var
|
|
57923
|
+
var import_react264 = require("react");
|
|
57913
57924
|
var useChannelsQueryState = () => {
|
|
57914
|
-
const [error, setError] = (0,
|
|
57915
|
-
const [queryInProgress, setQueryInProgress] = (0,
|
|
57925
|
+
const [error, setError] = (0, import_react264.useState)(null);
|
|
57926
|
+
const [queryInProgress, setQueryInProgress] = (0, import_react264.useState)("uninitialized");
|
|
57916
57927
|
return {
|
|
57917
57928
|
error,
|
|
57918
57929
|
queryInProgress,
|
|
@@ -57947,7 +57958,7 @@ var Chat = (props) => {
|
|
|
57947
57958
|
translators
|
|
57948
57959
|
} = useChat({ client, defaultLanguage, i18nInstance, initialNavOpen });
|
|
57949
57960
|
const channelsQueryState = useChannelsQueryState();
|
|
57950
|
-
const searchController = (0,
|
|
57961
|
+
const searchController = (0, import_react265.useMemo)(
|
|
57951
57962
|
() => customChannelSearchController ?? new import_stream_chat6.SearchController({
|
|
57952
57963
|
sources: [
|
|
57953
57964
|
new import_stream_chat6.ChannelSearchSource(client),
|
|
@@ -57975,11 +57986,11 @@ var Chat = (props) => {
|
|
|
57975
57986
|
useImageFlagEmojisOnWindows
|
|
57976
57987
|
});
|
|
57977
57988
|
if (!translators.t) return null;
|
|
57978
|
-
return /* @__PURE__ */
|
|
57989
|
+
return /* @__PURE__ */ import_react265.default.createElement(ChatProvider, { value: chatContextValue }, /* @__PURE__ */ import_react265.default.createElement(TranslationProvider, { value: translators }, children));
|
|
57979
57990
|
};
|
|
57980
57991
|
|
|
57981
57992
|
// src/components/Chat/hooks/useCreateChatClient.ts
|
|
57982
|
-
var
|
|
57993
|
+
var import_react266 = require("react");
|
|
57983
57994
|
var import_stream_chat7 = require("stream-chat");
|
|
57984
57995
|
var useCreateChatClient = ({
|
|
57985
57996
|
apiKey,
|
|
@@ -57987,13 +57998,13 @@ var useCreateChatClient = ({
|
|
|
57987
57998
|
tokenOrProvider,
|
|
57988
57999
|
userData
|
|
57989
58000
|
}) => {
|
|
57990
|
-
const [chatClient, setChatClient] = (0,
|
|
57991
|
-
const [cachedUserData, setCachedUserData] = (0,
|
|
58001
|
+
const [chatClient, setChatClient] = (0, import_react266.useState)(null);
|
|
58002
|
+
const [cachedUserData, setCachedUserData] = (0, import_react266.useState)(userData);
|
|
57992
58003
|
if (userData.id !== cachedUserData.id) {
|
|
57993
58004
|
setCachedUserData(userData);
|
|
57994
58005
|
}
|
|
57995
|
-
const [cachedOptions] = (0,
|
|
57996
|
-
(0,
|
|
58006
|
+
const [cachedOptions] = (0, import_react266.useState)(options);
|
|
58007
|
+
(0, import_react266.useEffect)(() => {
|
|
57997
58008
|
const client = new import_stream_chat7.StreamChat(apiKey, void 0, cachedOptions);
|
|
57998
58009
|
let didUserConnectInterrupt = false;
|
|
57999
58010
|
const connectionPromise = client.connectUser(cachedUserData, tokenOrProvider).then(() => {
|
|
@@ -58011,17 +58022,17 @@ var useCreateChatClient = ({
|
|
|
58011
58022
|
};
|
|
58012
58023
|
|
|
58013
58024
|
// src/components/Thread/Thread.tsx
|
|
58014
|
-
var
|
|
58025
|
+
var import_react271 = __toESM(require("react"));
|
|
58015
58026
|
var import_clsx66 = __toESM(require("clsx"));
|
|
58016
58027
|
|
|
58017
58028
|
// src/components/Thread/ThreadHeader.tsx
|
|
58018
|
-
var
|
|
58029
|
+
var import_react268 = __toESM(require("react"));
|
|
58019
58030
|
|
|
58020
58031
|
// src/components/Thread/icons.tsx
|
|
58021
|
-
var
|
|
58032
|
+
var import_react267 = __toESM(require("react"));
|
|
58022
58033
|
var CloseIcon3 = ({ title }) => {
|
|
58023
58034
|
const { t: t2 } = useTranslationContext("CloseIcon");
|
|
58024
|
-
return /* @__PURE__ */
|
|
58035
|
+
return /* @__PURE__ */ import_react267.default.createElement(
|
|
58025
58036
|
"svg",
|
|
58026
58037
|
{
|
|
58027
58038
|
"data-testid": "close-no-outline",
|
|
@@ -58029,8 +58040,8 @@ var CloseIcon3 = ({ title }) => {
|
|
|
58029
58040
|
viewBox: "0 0 24 24",
|
|
58030
58041
|
xmlns: "http://www.w3.org/2000/svg"
|
|
58031
58042
|
},
|
|
58032
|
-
/* @__PURE__ */
|
|
58033
|
-
/* @__PURE__ */
|
|
58043
|
+
/* @__PURE__ */ import_react267.default.createElement("title", null, title ?? t2("Close")),
|
|
58044
|
+
/* @__PURE__ */ import_react267.default.createElement(
|
|
58034
58045
|
"path",
|
|
58035
58046
|
{
|
|
58036
58047
|
d: "M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z",
|
|
@@ -58050,7 +58061,7 @@ var ThreadHeader = (props) => {
|
|
|
58050
58061
|
overrideImage,
|
|
58051
58062
|
overrideTitle
|
|
58052
58063
|
});
|
|
58053
|
-
return /* @__PURE__ */
|
|
58064
|
+
return /* @__PURE__ */ import_react268.default.createElement("div", { className: "str-chat__thread-header" }, /* @__PURE__ */ import_react268.default.createElement("div", { className: "str-chat__thread-header-details" }, /* @__PURE__ */ import_react268.default.createElement("div", { className: "str-chat__thread-header-title" }, t2("Thread")), /* @__PURE__ */ import_react268.default.createElement("div", { className: "str-chat__thread-header-subtitle" }, displayTitle)), /* @__PURE__ */ import_react268.default.createElement(
|
|
58054
58065
|
"button",
|
|
58055
58066
|
{
|
|
58056
58067
|
"aria-label": t2("aria/Close thread"),
|
|
@@ -58058,26 +58069,26 @@ var ThreadHeader = (props) => {
|
|
|
58058
58069
|
"data-testid": "close-button",
|
|
58059
58070
|
onClick: closeThread
|
|
58060
58071
|
},
|
|
58061
|
-
/* @__PURE__ */
|
|
58072
|
+
/* @__PURE__ */ import_react268.default.createElement(CloseIcon3, null)
|
|
58062
58073
|
));
|
|
58063
58074
|
};
|
|
58064
58075
|
|
|
58065
58076
|
// src/components/Thread/ThreadHead.tsx
|
|
58066
|
-
var
|
|
58077
|
+
var import_react270 = __toESM(require("react"));
|
|
58067
58078
|
|
|
58068
58079
|
// src/components/Thread/ThreadStart.tsx
|
|
58069
|
-
var
|
|
58080
|
+
var import_react269 = __toESM(require("react"));
|
|
58070
58081
|
var ThreadStart = () => {
|
|
58071
58082
|
const { thread } = useChannelStateContext("ThreadStart");
|
|
58072
58083
|
const { t: t2 } = useTranslationContext("ThreadStart");
|
|
58073
58084
|
if (!thread?.reply_count) return null;
|
|
58074
|
-
return /* @__PURE__ */
|
|
58085
|
+
return /* @__PURE__ */ import_react269.default.createElement("div", { className: "str-chat__thread-start" }, t2("replyCount", { count: thread.reply_count }));
|
|
58075
58086
|
};
|
|
58076
58087
|
|
|
58077
58088
|
// src/components/Thread/ThreadHead.tsx
|
|
58078
58089
|
var ThreadHead = (props) => {
|
|
58079
58090
|
const { ThreadStart: ThreadStart2 = ThreadStart } = useComponentContext("ThreadHead");
|
|
58080
|
-
return /* @__PURE__ */
|
|
58091
|
+
return /* @__PURE__ */ import_react270.default.createElement("div", { className: "str-chat__parent-message-li" }, /* @__PURE__ */ import_react270.default.createElement(Message, { initialMessage: true, threadList: true, ...props }), /* @__PURE__ */ import_react270.default.createElement(ThreadStart2, null));
|
|
58081
58092
|
};
|
|
58082
58093
|
|
|
58083
58094
|
// src/components/Thread/Thread.tsx
|
|
@@ -58087,7 +58098,7 @@ var Thread = (props) => {
|
|
|
58087
58098
|
if (!thread && !threadInstance || channelConfig?.replies === false) return null;
|
|
58088
58099
|
return (
|
|
58089
58100
|
// FIXME: TS is having trouble here as at least one of the two would always be defined
|
|
58090
|
-
/* @__PURE__ */
|
|
58101
|
+
/* @__PURE__ */ import_react271.default.createElement(
|
|
58091
58102
|
ThreadInner,
|
|
58092
58103
|
{
|
|
58093
58104
|
...props,
|
|
@@ -58138,7 +58149,7 @@ var ThreadInner = (props) => {
|
|
|
58138
58149
|
const FallbackMessage = virtualized && VirtualMessage ? VirtualMessage : ContextMessage;
|
|
58139
58150
|
const MessageUIComponent = ThreadMessage || FallbackMessage;
|
|
58140
58151
|
const ThreadMessageList = virtualized ? VirtualizedMessageList : MessageList;
|
|
58141
|
-
(0,
|
|
58152
|
+
(0, import_react271.useEffect)(() => {
|
|
58142
58153
|
if (thread?.id && thread?.reply_count) {
|
|
58143
58154
|
loadMoreThread();
|
|
58144
58155
|
}
|
|
@@ -58160,7 +58171,7 @@ var ThreadInner = (props) => {
|
|
|
58160
58171
|
const threadClass = customClasses?.thread || (0, import_clsx66.default)("str-chat__thread-container str-chat__thread", {
|
|
58161
58172
|
"str-chat__thread--virtualized": virtualized
|
|
58162
58173
|
});
|
|
58163
|
-
const head = /* @__PURE__ */
|
|
58174
|
+
const head = /* @__PURE__ */ import_react271.default.createElement(
|
|
58164
58175
|
ThreadHead2,
|
|
58165
58176
|
{
|
|
58166
58177
|
key: messageAsThread.id,
|
|
@@ -58169,7 +58180,7 @@ var ThreadInner = (props) => {
|
|
|
58169
58180
|
...additionalParentMessageProps
|
|
58170
58181
|
}
|
|
58171
58182
|
);
|
|
58172
|
-
return /* @__PURE__ */
|
|
58183
|
+
return /* @__PURE__ */ import_react271.default.createElement("div", { className: threadClass }, /* @__PURE__ */ import_react271.default.createElement(ThreadHeader2, { closeThread, thread: messageAsThread }), /* @__PURE__ */ import_react271.default.createElement(
|
|
58173
58184
|
ThreadMessageList,
|
|
58174
58185
|
{
|
|
58175
58186
|
disableDateSeparator: !enableDateSeparator,
|
|
@@ -58181,7 +58192,7 @@ var ThreadInner = (props) => {
|
|
|
58181
58192
|
...threadProps,
|
|
58182
58193
|
...virtualized ? additionalVirtualizedMessageListProps : additionalMessageListProps
|
|
58183
58194
|
}
|
|
58184
|
-
), /* @__PURE__ */
|
|
58195
|
+
), /* @__PURE__ */ import_react271.default.createElement(
|
|
58185
58196
|
MessageInput,
|
|
58186
58197
|
{
|
|
58187
58198
|
focus: autoFocus,
|
|
@@ -58195,12 +58206,12 @@ var ThreadInner = (props) => {
|
|
|
58195
58206
|
};
|
|
58196
58207
|
|
|
58197
58208
|
// src/components/Window/Window.tsx
|
|
58198
|
-
var
|
|
58209
|
+
var import_react272 = __toESM(require("react"));
|
|
58199
58210
|
var import_clsx67 = __toESM(require("clsx"));
|
|
58200
58211
|
var UnMemoizedWindow = (props) => {
|
|
58201
58212
|
const { children, thread: propThread } = props;
|
|
58202
58213
|
const { thread: contextThread } = useChannelStateContext("Window");
|
|
58203
|
-
return /* @__PURE__ */
|
|
58214
|
+
return /* @__PURE__ */ import_react272.default.createElement(
|
|
58204
58215
|
"div",
|
|
58205
58216
|
{
|
|
58206
58217
|
className: (0, import_clsx67.default)("str-chat__main-panel", {
|
|
@@ -58210,7 +58221,7 @@ var UnMemoizedWindow = (props) => {
|
|
|
58210
58221
|
children
|
|
58211
58222
|
);
|
|
58212
58223
|
};
|
|
58213
|
-
var Window =
|
|
58224
|
+
var Window = import_react272.default.memo(UnMemoizedWindow);
|
|
58214
58225
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58215
58226
|
0 && (module.exports = {
|
|
58216
58227
|
ACTIONS_NOT_WORKING_IN_THREAD,
|