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