UNPKG

@sendbird/uikit-react

Version:

Sendbird UIKit for React: A feature-rich and customizable chat UI kit with messaging, channel management, and user authentication.

41 lines (38 loc) 2.58 kB
import { i as isSameDay } from '../../chunks/bundle-Cl9rtdlj.js'; import { compareMessagesForGrouping } from './compareMessagesForGrouping.js'; import { b as isAdminMessage } from '../../chunks/bundle-vmZ9LoYK.js'; import '../../chunks/bundle-fdEQfX2s.js'; import '../../chunks/bundle-mGsud0ec.js'; import '../../chunks/bundle-BZGITC2g.js'; import '../../chunks/bundle-yl5d1NoZ.js'; import '@sendbird/chat/groupChannel'; import '../../utils/message/getOutgoingMessageState.js'; import '../../chunks/bundle-DgosLQK9.js'; import '../../chunks/bundle-DEuCwnTn.js'; import '../../chunks/bundle-CqLLOVG5.js'; /** * exported, should be backward compatible */ var getMessagePartsInfo = function (_a) { var allMessages = _a.allMessages, stringSet = _a.stringSet, _b = _a.isMessageGroupingEnabled, isMessageGroupingEnabled = _b === void 0 ? true : _b, _c = _a.currentIndex, currentIndex = _c === void 0 ? 0 : _c, currentMessage = _a.currentMessage, _d = _a.currentChannel, currentChannel = _d === void 0 ? null : _d, _e = _a.replyType, replyType = _e === void 0 ? '' : _e, firstUnreadMessageId = _a.firstUnreadMessageId, isUnreadMessageExistInChannel = _a.isUnreadMessageExistInChannel; var previousMessage = allMessages[currentIndex - 1]; var nextMessage = allMessages[currentIndex + 1]; var _f = isMessageGroupingEnabled ? compareMessagesForGrouping(previousMessage, currentMessage, nextMessage, stringSet, currentChannel, replyType) : [false, false], chainTop = _f[0], chainBottom = _f[1]; var previousMessageCreatedAt = previousMessage === null || previousMessage === void 0 ? void 0 : previousMessage.createdAt; var currentCreatedAt = currentMessage.createdAt; // NOTE: for pending/failed messages var isLocalMessage = 'sendingStatus' in currentMessage && (currentMessage.sendingStatus !== 'succeeded'); // https://stackoverflow.com/a/41855608 var hasSeparator = isLocalMessage ? false : !(previousMessageCreatedAt && (isSameDay(currentCreatedAt, previousMessageCreatedAt))); var hasNewMessageSeparator = (isLocalMessage || !(isUnreadMessageExistInChannel === null || isUnreadMessageExistInChannel === void 0 ? void 0 : isUnreadMessageExistInChannel.current)) ? false : (!isAdminMessage(currentMessage) && firstUnreadMessageId === currentMessage.messageId); return { chainTop: chainTop, chainBottom: chainBottom, hasSeparator: hasSeparator, hasNewMessageSeparator: hasNewMessageSeparator, }; }; export { getMessagePartsInfo }; //# sourceMappingURL=getMessagePartsInfo.js.map