@sendbird/uikit-utils 3.0.4 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,12 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.calcMessageGrouping = calcMessageGrouping;
7
+ exports.convertFileTypeToMessageType = void 0;
7
8
  exports.getAvailableUriFromFileMessage = getAvailableUriFromFileMessage;
8
9
  exports.getDefaultMessageSearchQueryParams = getDefaultMessageSearchQueryParams;
10
+ exports.getFileIconFromMessageType = exports.getFileIconFromMessage = void 0;
9
11
  exports.getFileTypeFromMessage = getFileTypeFromMessage;
10
12
  exports.getMessageType = getMessageType;
11
13
  exports.getMessageUniqId = getMessageUniqId;
12
14
  exports.getReactionCount = getReactionCount;
15
+ exports.getThumbnailUriFromFileMessage = getThumbnailUriFromFileMessage;
13
16
  exports.hasSameSender = hasSameSender;
14
17
  exports.isMyMessage = isMyMessage;
15
18
  exports.isNewMessage = isNewMessage;
@@ -18,6 +21,7 @@ exports.isSendbirdNotification = isSendbirdNotification;
18
21
  exports.messageComparator = messageComparator;
19
22
  exports.messageKeyExtractor = messageKeyExtractor;
20
23
  exports.parseSendbirdNotification = parseSendbirdNotification;
24
+ exports.shouldRenderParentMessage = shouldRenderParentMessage;
21
25
  exports.shouldRenderReaction = shouldRenderReaction;
22
26
  var _message = require("@sendbird/chat/message");
23
27
  var _file = require("../shared/file");
@@ -35,7 +39,7 @@ function isMyMessage(msg) {
35
39
  var _msg$sender;
36
40
  let currentUserId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '##__USER_ID_IS_NOT_PROVIDED__##';
37
41
  if (!isSendableMessage(msg)) return false;
38
- return 'sender' in msg && ((_msg$sender = msg.sender) === null || _msg$sender === void 0 ? void 0 : _msg$sender.userId) === currentUserId || msg.sendingStatus === 'pending' || msg.sendingStatus === 'failed' || msg.sendingStatus === 'canceled';
42
+ return ((_msg$sender = msg.sender) === null || _msg$sender === void 0 ? void 0 : _msg$sender.userId) === currentUserId;
39
43
  }
40
44
  function messageKeyExtractor(message) {
41
45
  return getMessageUniqId(message);
@@ -52,8 +56,8 @@ function messageKeyExtractor(message) {
52
56
  function messageComparator(a, b) {
53
57
  let aStatusOffset = 0;
54
58
  let bStatusOffset = 0;
55
- if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;
56
- if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;
59
+ if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = Number.MAX_SAFE_INTEGER;
60
+ if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = Number.MAX_SAFE_INTEGER;
57
61
  return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);
58
62
  }
59
63
  function hasSameSender(a, b) {
@@ -91,8 +95,15 @@ function getMessageUniqId(msg) {
91
95
  }
92
96
  return String(msg.messageId);
93
97
  }
98
+ function getThumbnailUriFromFileMessage(message) {
99
+ if (message.thumbnails && message.thumbnails.length > 0) {
100
+ return message.thumbnails[0].url;
101
+ }
102
+ return getAvailableUriFromFileMessage(message);
103
+ }
94
104
  function getAvailableUriFromFileMessage(message) {
95
- if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {
105
+ var _message$messageParam;
106
+ if (!message.url && (_message$messageParam = message.messageParams) !== null && _message$messageParam !== void 0 && _message$messageParam.file && 'uri' in message.messageParams.file) {
96
107
  return message.messageParams.file.uri;
97
108
  }
98
109
  return message.url;
@@ -104,6 +115,10 @@ function isSendbirdNotification(dataPayload) {
104
115
  function parseSendbirdNotification(dataPayload) {
105
116
  return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;
106
117
  }
118
+ function shouldRenderParentMessage(message) {
119
+ var _message$parentMessag, _message$parentMessag2;
120
+ return !!((message.isFileMessage() || message.isUserMessage()) && ((_message$parentMessag = message.parentMessage) !== null && _message$parentMessag !== void 0 && _message$parentMessag.isFileMessage() || (_message$parentMessag2 = message.parentMessage) !== null && _message$parentMessag2 !== void 0 && _message$parentMessag2.isUserMessage()));
121
+ }
107
122
  function shouldRenderReaction(channel, reactionEnabled) {
108
123
  if (channel.isOpenChannel()) {
109
124
  return false;
@@ -118,9 +133,48 @@ function shouldRenderReaction(channel, reactionEnabled) {
118
133
  function getReactionCount(reaction) {
119
134
  return reaction.userIds.length;
120
135
  }
136
+ const fileIconMapper = {
137
+ 'audio': 'file-audio',
138
+ 'image': 'photo',
139
+ 'video': 'play',
140
+ 'file': 'file-document'
141
+ };
121
142
  function getFileTypeFromMessage(message) {
122
143
  return (0, _file.getFileType)(message.type || (0, _file.getFileExtension)(message.name));
123
144
  }
145
+ const convertFileTypeToMessageType = function () {
146
+ let fileType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'file';
147
+ switch (fileType) {
148
+ case 'audio':
149
+ case 'image':
150
+ case 'video':
151
+ return `file.${fileType}`;
152
+ case 'file':
153
+ return fileType;
154
+ }
155
+ };
156
+ exports.convertFileTypeToMessageType = convertFileTypeToMessageType;
157
+ const getFileIconFromMessageType = messageType => {
158
+ switch (messageType) {
159
+ case 'file':
160
+ return fileIconMapper['file'];
161
+ case 'file.image':
162
+ return fileIconMapper['image'];
163
+ case 'file.video':
164
+ return fileIconMapper['video'];
165
+ case 'file.audio':
166
+ return fileIconMapper['audio'];
167
+ default:
168
+ return fileIconMapper['file'];
169
+ }
170
+ };
171
+ exports.getFileIconFromMessageType = getFileIconFromMessageType;
172
+ const getFileIconFromMessage = message => {
173
+ const fileType = getFileTypeFromMessage(message);
174
+ const messageType = convertFileTypeToMessageType(fileType);
175
+ return getFileIconFromMessageType(messageType);
176
+ };
177
+ exports.getFileIconFromMessage = getFileIconFromMessage;
124
178
  function getMessageType(message) {
125
179
  if (message.isAdminMessage()) {
126
180
  return 'admin';
@@ -1 +1 @@
1
- {"version":3,"names":["_message","require","_file","_common","isNewMessage","msg","currentUserId","myMessage","isMyMessage","isAdminMessage","updatedAt","isSendableMessage","undefined","_msg$sender","arguments","length","sender","userId","sendingStatus","messageKeyExtractor","message","getMessageUniqId","messageComparator","a","b","aStatusOffset","bStatusOffset","createdAt","hasSameSender","_a$sender","_b$sender","calcMessageGrouping","groupEnabled","curr","prev","next","getPrev","getMessageTimeFormat","Date","getNext","groupWithPrev","groupWithNext","isUserMessage","isFileMessage","String","messageId","reqId","getAvailableUriFromFileMessage","url","messageParams","file","uri","isSendbirdNotification","dataPayload","Boolean","parseSendbirdNotification","sendbird","JSON","parse","shouldRenderReaction","channel","reactionEnabled","isOpenChannel","isGroupChannel","isBroadcast","isSuper","isEphemeral","getReactionCount","reaction","userIds","getFileTypeFromMessage","getFileType","type","getFileExtension","name","getMessageType","ogMetaData","fileType","getDefaultMessageSearchQueryParams","keyword","channelUrl","messageTimestampFrom","Math","max","joinedAt","invitedAt","order","MessageSearchOrder","TIMESTAMP"],"sources":["message.ts"],"sourcesContent":["import { MessageSearchOrder } from '@sendbird/chat/message';\n\nimport { getFileExtension, getFileType } from '../shared/file';\nimport type {\n SendbirdBaseChannel,\n SendbirdBaseMessage,\n SendbirdDataPayload,\n SendbirdFileMessage,\n SendbirdGroupChannel,\n SendbirdMessage,\n SendbirdReaction,\n SendbirdSendableMessage,\n} from '../types';\nimport { getMessageTimeFormat } from '../ui-format/common';\n\nexport function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {\n const myMessage = isMyMessage(msg, currentUserId);\n if (myMessage) return false;\n if (msg.isAdminMessage()) return false;\n return msg.updatedAt === 0;\n}\n\nexport function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage {\n return msg !== undefined && msg !== null && 'sendingStatus' in msg;\n}\n\nexport function isMyMessage(msg?: SendbirdMessage | null, currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##') {\n if (!isSendableMessage(msg)) return false;\n return (\n ('sender' in msg && msg.sender?.userId === currentUserId) ||\n msg.sendingStatus === 'pending' ||\n msg.sendingStatus === 'failed' ||\n msg.sendingStatus === 'canceled'\n );\n}\n\nexport function messageKeyExtractor(message: SendbirdMessage): string {\n return getMessageUniqId(message);\n}\n\n// |-------------------|-------------------|-----------------|-------------------|\n// | sending status | reqId | messageId | createdAt |\n// |-------------------|-------------------|-----------------|-------------------|\n// | pending | timestamp(A) | 0 | timestamp(B) |\n// | canceled | timestamp(A) | 0 | ? |\n// | failed | timestamp(A) | 0 | ? |\n// | succeeded | timestamp(A) / '' | id from DB | timestamp(C) |\n// |-------------------|-------------------|-----------------|-------------------|\nexport function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {\n let aStatusOffset = 0;\n let bStatusOffset = 0;\n\n if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;\n if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;\n\n return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);\n}\n\nexport function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage) {\n if (!a || !b) return false;\n if ('sender' in a && 'sender' in b) return a.sender?.userId === b.sender?.userId;\n return false;\n}\n\nexport function calcMessageGrouping(\n groupEnabled: boolean,\n curr: SendbirdMessage,\n prev?: SendbirdMessage,\n next?: SendbirdMessage,\n) {\n const getPrev = () => {\n if (!groupEnabled) return false;\n if (!prev) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, prev)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(prev.createdAt))) return false;\n return true;\n };\n\n const getNext = () => {\n if (!groupEnabled) return false;\n if (!next) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, next)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(next.createdAt))) return false;\n return true;\n };\n\n return { groupWithPrev: getPrev(), groupWithNext: getNext() };\n}\n\nexport function getMessageUniqId(msg: SendbirdBaseMessage) {\n if (msg.isUserMessage() || msg.isFileMessage()) {\n if (msg.sendingStatus === 'succeeded') return String(msg.messageId);\n return msg.reqId;\n }\n\n return String(msg.messageId);\n}\n\nexport function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {\n if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {\n return message.messageParams.file.uri;\n }\n return message.url;\n}\n\ntype RawSendbirdDataPayload = { sendbird: string | object };\nexport function isSendbirdNotification(dataPayload?: {\n [key: string]: string | object;\n}): dataPayload is RawSendbirdDataPayload {\n if (!dataPayload) return false;\n return Boolean(dataPayload['sendbird']);\n}\n\nexport function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload {\n return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;\n}\n\nexport function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean) {\n if (channel.isOpenChannel()) {\n return false;\n }\n\n if (channel.isGroupChannel()) {\n if (channel.isBroadcast) return false;\n if (channel.isSuper) return false;\n if (channel.isEphemeral) return false;\n }\n\n return reactionEnabled;\n}\n\nexport function getReactionCount(reaction: SendbirdReaction) {\n return reaction.userIds.length;\n}\n\ntype MessageType =\n | 'user'\n | 'admin'\n | 'file'\n | 'unknown'\n | `user.${'opengraph'}`\n | `file.${'image' | 'video' | 'audio'}`;\n\nexport function getFileTypeFromMessage(message: SendbirdFileMessage) {\n return getFileType(message.type || getFileExtension(message.name));\n}\n\nexport function getMessageType(message: SendbirdMessage): MessageType {\n if (message.isAdminMessage()) {\n return 'admin';\n }\n\n if (message.isUserMessage()) {\n if (message.ogMetaData) {\n return 'user.opengraph';\n }\n return 'user';\n }\n\n if (message.isFileMessage()) {\n const fileType = getFileTypeFromMessage(message);\n switch (fileType) {\n case 'image':\n case 'video': {\n return `file.${fileType}`;\n }\n case 'audio': {\n return `file.${fileType}`;\n }\n default: {\n return 'file';\n }\n }\n }\n\n return 'unknown';\n}\n\nexport function getDefaultMessageSearchQueryParams(channel: SendbirdGroupChannel, keyword: string) {\n return {\n keyword,\n channelUrl: channel.url,\n messageTimestampFrom: Math.max(channel.joinedAt, channel.invitedAt),\n order: MessageSearchOrder.TIMESTAMP,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAWA,IAAAE,OAAA,GAAAF,OAAA;AAEO,SAASG,YAAYA,CAACC,GAAoB,EAAEC,aAAsB,EAAE;EACzE,MAAMC,SAAS,GAAGC,WAAW,CAACH,GAAG,EAAEC,aAAa,CAAC;EACjD,IAAIC,SAAS,EAAE,OAAO,KAAK;EAC3B,IAAIF,GAAG,CAACI,cAAc,EAAE,EAAE,OAAO,KAAK;EACtC,OAAOJ,GAAG,CAACK,SAAS,KAAK,CAAC;AAC5B;AAEO,SAASC,iBAAiBA,CAACN,GAA4B,EAAkC;EAC9F,OAAOA,GAAG,KAAKO,SAAS,IAAIP,GAAG,KAAK,IAAI,IAAI,eAAe,IAAIA,GAAG;AACpE;AAEO,SAASG,WAAWA,CAACH,GAA4B,EAAqD;EAAA,IAAAQ,WAAA;EAAA,IAAnDP,aAAa,GAAAQ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAF,SAAA,GAAAE,SAAA,MAAG,iCAAiC;EACzG,IAAI,CAACH,iBAAiB,CAACN,GAAG,CAAC,EAAE,OAAO,KAAK;EACzC,OACG,QAAQ,IAAIA,GAAG,IAAI,EAAAQ,WAAA,GAAAR,GAAG,CAACW,MAAM,cAAAH,WAAA,uBAAVA,WAAA,CAAYI,MAAM,MAAKX,aAAa,IACxDD,GAAG,CAACa,aAAa,KAAK,SAAS,IAC/Bb,GAAG,CAACa,aAAa,KAAK,QAAQ,IAC9Bb,GAAG,CAACa,aAAa,KAAK,UAAU;AAEpC;AAEO,SAASC,mBAAmBA,CAACC,OAAwB,EAAU;EACpE,OAAOC,gBAAgB,CAACD,OAAO,CAAC;AAClC;;AAEA;AACA;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B;IACzB;IACA,OAAO,MAAM;EACf;EAEA,IAAIxD,OAAO,CAACuB,aAAa,EAAE,EAAE;IAC3B,MAAMkC,QAAQ,GAAGP,sBAAsB,CAAClD,OAAO,CAAC;IAChD,QAAQyD,QAAQ;MACd,KAAK,OAAO;MACZ,KAAK,OAAO;QAAE;UACZ,OAAQ,QAAOA,QAAS,EAAC;QAC3B;MACA,KAAK,OAAO;QAAE;UACZ,OAAQ,QAAOA,QAAS,EAAC;QAC3B;MACA;QAAS;UACP,OAAO,MAAM;QACf;IAAC;EAEL;EAEA,OAAO,SAAS;AAClB;AAEO,SAASC,kCAAkCA,CAAClB,OAA6B,EAAEmB,OAAe,EAAE;EACjG,OAAO;IACLA,OAAO;IACPC,UAAU,EAAEpB,OAAO,CAACZ,GAAG;IACvBiC,oBAAoB,EAAEC,IAAI,CAACC,GAAG,CAACvB,OAAO,CAACwB,QAAQ,EAAExB,OAAO,CAACyB,SAAS,CAAC;IACnEC,KAAK,EAAEC,2BAAkB,CAACC;EAC5B,CAAC;AACH"}
1
+ {"version":3,"names":["_message","require","_file","_common","isNewMessage","msg","currentUserId","myMessage","isMyMessage","isAdminMessage","updatedAt","isSendableMessage","undefined","_msg$sender","arguments","length","sender","userId","messageKeyExtractor","message","getMessageUniqId","messageComparator","a","b","aStatusOffset","bStatusOffset","sendingStatus","Number","MAX_SAFE_INTEGER","createdAt","hasSameSender","_a$sender","_b$sender","calcMessageGrouping","groupEnabled","curr","prev","next","getPrev","getMessageTimeFormat","Date","getNext","groupWithPrev","groupWithNext","isUserMessage","isFileMessage","String","messageId","reqId","getThumbnailUriFromFileMessage","thumbnails","url","getAvailableUriFromFileMessage","_message$messageParam","messageParams","file","uri","isSendbirdNotification","dataPayload","Boolean","parseSendbirdNotification","sendbird","JSON","parse","shouldRenderParentMessage","_message$parentMessag","_message$parentMessag2","parentMessage","shouldRenderReaction","channel","reactionEnabled","isOpenChannel","isGroupChannel","isBroadcast","isSuper","isEphemeral","getReactionCount","reaction","userIds","fileIconMapper","getFileTypeFromMessage","getFileType","type","getFileExtension","name","convertFileTypeToMessageType","fileType","exports","getFileIconFromMessageType","messageType","getFileIconFromMessage","getMessageType","ogMetaData","getDefaultMessageSearchQueryParams","keyword","channelUrl","messageTimestampFrom","Math","max","joinedAt","invitedAt","order","MessageSearchOrder","TIMESTAMP"],"sources":["message.ts"],"sourcesContent":["import { MessageSearchOrder } from '@sendbird/chat/message';\n\nimport { getFileExtension, getFileType } from '../shared/file';\nimport type {\n SendbirdBaseChannel,\n SendbirdBaseMessage,\n SendbirdDataPayload,\n SendbirdFileMessage,\n SendbirdGroupChannel,\n SendbirdMessage,\n SendbirdReaction,\n SendbirdSendableMessage,\n SendbirdUserMessage,\n} from '../types';\nimport { getMessageTimeFormat } from '../ui-format/common';\n\nexport function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {\n const myMessage = isMyMessage(msg, currentUserId);\n if (myMessage) return false;\n if (msg.isAdminMessage()) return false;\n return msg.updatedAt === 0;\n}\n\nexport function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage {\n return msg !== undefined && msg !== null && 'sendingStatus' in msg;\n}\n\nexport function isMyMessage(\n msg?: SendbirdMessage | null,\n currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##',\n): msg is SendbirdSendableMessage {\n if (!isSendableMessage(msg)) return false;\n return msg.sender?.userId === currentUserId;\n}\n\nexport function messageKeyExtractor(message: SendbirdMessage): string {\n return getMessageUniqId(message);\n}\n\n// |-------------------|-------------------|-----------------|-------------------|\n// | sending status | reqId | messageId | createdAt |\n// |-------------------|-------------------|-----------------|-------------------|\n// | pending | timestamp(A) | 0 | timestamp(B) |\n// | canceled | timestamp(A) | 0 | ? |\n// | failed | timestamp(A) | 0 | ? |\n// | succeeded | timestamp(A) / '' | id from DB | timestamp(C) |\n// |-------------------|-------------------|-----------------|-------------------|\nexport function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {\n let aStatusOffset = 0;\n let bStatusOffset = 0;\n\n if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = Number.MAX_SAFE_INTEGER;\n if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = Number.MAX_SAFE_INTEGER;\n\n return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);\n}\n\nexport function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage) {\n if (!a || !b) return false;\n if ('sender' in a && 'sender' in b) return a.sender?.userId === b.sender?.userId;\n return false;\n}\n\nexport function calcMessageGrouping(\n groupEnabled: boolean,\n curr: SendbirdMessage,\n prev?: SendbirdMessage,\n next?: SendbirdMessage,\n) {\n const getPrev = () => {\n if (!groupEnabled) return false;\n if (!prev) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, prev)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(prev.createdAt))) return false;\n return true;\n };\n\n const getNext = () => {\n if (!groupEnabled) return false;\n if (!next) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, next)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(next.createdAt))) return false;\n return true;\n };\n\n return { groupWithPrev: getPrev(), groupWithNext: getNext() };\n}\n\nexport function getMessageUniqId(msg: SendbirdBaseMessage) {\n if (msg.isUserMessage() || msg.isFileMessage()) {\n if (msg.sendingStatus === 'succeeded') return String(msg.messageId);\n return msg.reqId;\n }\n\n return String(msg.messageId);\n}\n\nexport function getThumbnailUriFromFileMessage(message: SendbirdFileMessage) {\n if (message.thumbnails && message.thumbnails.length > 0) {\n return message.thumbnails[0].url;\n }\n\n return getAvailableUriFromFileMessage(message);\n}\n\nexport function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {\n if (!message.url && message.messageParams?.file && 'uri' in message.messageParams.file) {\n return message.messageParams.file.uri;\n }\n\n return message.url;\n}\n\ntype RawSendbirdDataPayload = { sendbird: string | object };\nexport function isSendbirdNotification(dataPayload?: {\n [key: string]: string | object;\n}): dataPayload is RawSendbirdDataPayload {\n if (!dataPayload) return false;\n return Boolean(dataPayload['sendbird']);\n}\n\nexport function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload {\n return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;\n}\n\nexport function shouldRenderParentMessage(message: SendbirdMessage): message is (\n | SendbirdUserMessage\n | SendbirdFileMessage\n) & {\n parentMessage: SendbirdUserMessage | SendbirdFileMessage;\n} {\n return !!(\n (message.isFileMessage() || message.isUserMessage()) &&\n (message.parentMessage?.isFileMessage() || message.parentMessage?.isUserMessage())\n );\n}\n\nexport function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean) {\n if (channel.isOpenChannel()) {\n return false;\n }\n\n if (channel.isGroupChannel()) {\n if (channel.isBroadcast) return false;\n if (channel.isSuper) return false;\n if (channel.isEphemeral) return false;\n }\n\n return reactionEnabled;\n}\n\nexport function getReactionCount(reaction: SendbirdReaction) {\n return reaction.userIds.length;\n}\n\nexport type MessageType =\n | 'user'\n | 'admin'\n | 'file'\n | 'unknown'\n | `user.${'opengraph'}`\n | `file.${'image' | 'video' | 'audio'}`;\n\nexport type FileType = 'file' | 'image' | 'audio' | 'video';\n\nconst fileIconMapper = {\n 'audio': 'file-audio',\n 'image': 'photo',\n 'video': 'play',\n 'file': 'file-document',\n} as const;\n\ntype ValueOf<T> = T[keyof T];\nexport type FileIcon = ValueOf<typeof fileIconMapper>;\n\nexport function getFileTypeFromMessage(message: SendbirdFileMessage): FileType {\n return getFileType(message.type || getFileExtension(message.name));\n}\nexport const convertFileTypeToMessageType = (fileType: FileType = 'file'): MessageType => {\n switch (fileType) {\n case 'audio':\n case 'image':\n case 'video':\n return `file.${fileType}`;\n case 'file':\n return fileType;\n }\n};\nexport const getFileIconFromMessageType = (messageType: MessageType): FileIcon => {\n switch (messageType) {\n case 'file':\n return fileIconMapper['file'];\n case 'file.image':\n return fileIconMapper['image'];\n case 'file.video':\n return fileIconMapper['video'];\n case 'file.audio':\n return fileIconMapper['audio'];\n default:\n return fileIconMapper['file'];\n }\n};\nexport const getFileIconFromMessage = (message: SendbirdFileMessage): FileIcon => {\n const fileType = getFileTypeFromMessage(message);\n const messageType = convertFileTypeToMessageType(fileType);\n return getFileIconFromMessageType(messageType);\n};\n\nexport function getMessageType(message: SendbirdMessage): MessageType {\n if (message.isAdminMessage()) {\n return 'admin';\n }\n\n if (message.isUserMessage()) {\n if (message.ogMetaData) {\n return 'user.opengraph';\n }\n return 'user';\n }\n\n if (message.isFileMessage()) {\n const fileType = getFileTypeFromMessage(message);\n switch (fileType) {\n case 'image':\n case 'video': {\n return `file.${fileType}`;\n }\n case 'audio': {\n return `file.${fileType}`;\n }\n default: {\n return 'file';\n }\n }\n }\n\n return 'unknown';\n}\n\nexport function getDefaultMessageSearchQueryParams(channel: SendbirdGroupChannel, keyword: string) {\n return {\n keyword,\n channelUrl: channel.url,\n messageTimestampFrom: Math.max(channel.joinedAt, channel.invitedAt),\n order: MessageSearchOrder.TIMESTAMP,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAYA,IAAAE,OAAA,GAAAF,OAAA;AAEO,SAASG,YAAYA,CAACC,GAAoB,EAAEC,aAAsB,EAAE;EACzE,MAAMC,SAAS,GAAGC,WAAW,CAACH,GAAG,EAAEC,aAAa,CAAC;EACjD,IAAIC,SAAS,EAAE,OAAO,KAAK;EAC3B,IAAIF,GAAG,CAACI,cAAc,EAAE,EAAE,OAAO,KAAK;EACtC,OAAOJ,GAAG,CAACK,SAAS,KAAK,CAAC;AAC5B;AAEO,SAASC,iBAAiBA,CAACN,GAA4B,EAAkC;EAC9F,OAAOA,GAAG,KAAKO,SAAS,IAAIP,GAAG,KAAK,IAAI,IAAI,eAAe,IAAIA,GAAG;AACpE;AAEO,SA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Z,KAAK,OAAO;QAAE;UACZ,OAAQ,QAAOA,QAAS,EAAC;QAC3B;MACA,KAAK,OAAO;QAAE;UACZ,OAAQ,QAAOA,QAAS,EAAC;QAC3B;MACA;QAAS;UACP,OAAO,MAAM;QACf;IAAC;EAEL;EAEA,OAAO,SAAS;AAClB;AAEO,SAASO,kCAAkCA,CAACxB,OAA6B,EAAEyB,OAAe,EAAE;EACjG,OAAO;IACLA,OAAO;IACPC,UAAU,EAAE1B,OAAO,CAAClB,GAAG;IACvB6C,oBAAoB,EAAEC,IAAI,CAACC,GAAG,CAAC7B,OAAO,CAAC8B,QAAQ,EAAE9B,OAAO,CAAC+B,SAAS,CAAC;IACnEC,KAAK,EAAEC,2BAAkB,CAACC;EAC5B,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"names":["ifOperator","role","then","or","getUserUniqId","user","userId"],"sources":["user.ts"],"sourcesContent":["import type { Role } from '@sendbird/chat';\n\nimport type { UserStruct } from '../types';\n\nexport function ifOperator<T>(role: Role, then: T): T | undefined;\nexport function ifOperator<T, V>(role: Role, then: T, or: V): T | V;\nexport function ifOperator(role: Role, then: unknown, or?: unknown) {\n if (role === 'operator') return then;\n return or;\n}\n\nexport function getUserUniqId<T extends UserStruct>(user: T) {\n return user.userId;\n}\n"],"mappings":";;;;;;;AAMO,SAASA,UAAUA,CAACC,IAAU,EAAEC,IAAa,EAAEC,EAAY,EAAE;EAClE,IAAIF,IAAI,KAAK,UAAU,EAAE,OAAOC,IAAI;EACpC,OAAOC,EAAE;AACX;AAEO,SAASC,aAAaA,CAAuBC,IAAO,EAAE;EAC3D,OAAOA,IAAI,CAACC,MAAM;AACpB"}
1
+ {"version":3,"names":["ifOperator","role","then","or","getUserUniqId","user","userId"],"sources":["user.ts"],"sourcesContent":["import type { Role } from '@sendbird/chat';\n\nimport type { UserStruct } from '../types';\n\nexport function ifOperator<T>(role: Role | null, then: T): T | undefined;\nexport function ifOperator<T, V>(role: Role | null, then: T, or: V): T | V;\nexport function ifOperator(role: Role | null, then: unknown, or?: unknown) {\n if (role === 'operator') return then;\n return or;\n}\n\nexport function getUserUniqId<T extends UserStruct>(user: T) {\n return user.userId;\n}\n"],"mappings":";;;;;;;AAMO,SAASA,UAAUA,CAACC,IAAiB,EAAEC,IAAa,EAAEC,EAAY,EAAE;EACzE,IAAIF,IAAI,KAAK,UAAU,EAAE,OAAOC,IAAI;EACpC,OAAOC,EAAE;AACX;AAEO,SAASC,aAAaA,CAAuBC,IAAO,EAAE;EAC3D,OAAOA,IAAI,CAACC,MAAM;AACpB"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type {\n BaseChannel,\n Emoji,\n EmojiCategory,\n EmojiContainer,\n Participant,\n RestrictedUser,\n SendbirdError as SBError,\n User,\n UserUpdateParams,\n} from '@sendbird/chat';\nimport type {\n GroupChannel,\n GroupChannelCollection,\n GroupChannelCreateParams,\n GroupChannelListQuery,\n GroupChannelModule,\n GroupChannelUpdateParams,\n Member,\n MessageCollection,\n} from '@sendbird/chat/groupChannel';\nimport type {\n ModuleNamespaces,\n OpenChannelCreateParams,\n OpenChannelUpdateParams,\n SendableMessage,\n} from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n MessageSearchQuery,\n MultipleFilesMessage,\n PreviousMessageListQuery,\n Reaction,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelListQuery, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nexport type FilterByValueType<T extends object, Type> = {\n [K in keyof T as T[K] extends Type ? K : never]: T[K];\n};\n\nexport type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void\n ? I\n : never;\n\nexport type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];\n\nexport type PartialDeep<T> = T extends object\n ? T extends Function\n ? T\n : {\n [P in keyof T]?: PartialDeep<T[P]>;\n }\n : T;\n\nexport type PartialNullable<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport type Optional<T> = T | undefined;\n\nexport type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;\n\nexport type OnBeforeHandler<T> = (params: T) => T | Promise<T>;\n\nexport interface UserStruct {\n userId: string;\n}\n\nexport type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;\nexport type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;\nexport type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;\nexport type SendbirdUserMessage = UserMessage;\nexport type SendbirdFileMessage = FileMessage;\nexport type SendbirdMultipleFilesMessage = MultipleFilesMessage;\nexport type SendbirdAdminMessage = AdminMessage;\nexport type SendbirdBaseMessage = BaseMessage;\nexport type SendbirdSendableMessage = SendableMessage;\nexport type SendbirdFileMessageCreateParams = FileMessageCreateParams;\nexport type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;\nexport type SendbirdUserMessageCreateParams = UserMessageCreateParams;\nexport type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;\n\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdOpenChannelCreateParams = OpenChannelCreateParams;\nexport type SendbirdOpenChannelUpdateParams = OpenChannelUpdateParams;\n\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdParticipant = Participant;\n\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\n\nexport type SendbirdReaction = Reaction;\nexport type SendbirdEmoji = Emoji;\nexport type SendbirdEmojiCategory = EmojiCategory;\nexport type SendbirdEmojiContainer = EmojiContainer;\n\nexport type SendbirdGroupChannelCollection = GroupChannelCollection;\nexport type SendbirdGroupChannelListQuery = GroupChannelListQuery;\nexport type SendbirdOpenChannelListQuery = OpenChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\nexport type SendbirdMessageSearchQuery = MessageSearchQuery;\n\nexport type SendbirdError = SBError;\n\nexport interface SendbirdDataPayload {\n app_id: string;\n audience_type: string;\n category: string;\n channel: {\n channel_unread_message_count: number;\n channel_url: string;\n custom_type: string;\n name: string;\n };\n channel_type: string;\n created_at: number;\n custom_type: string;\n files: NotificationFiles[];\n mentioned_users: NotificationMentionedUsers[];\n message: string;\n message_id: number;\n push_sound: string;\n push_title: null;\n recipient: {\n id: string;\n name: string;\n push_template: string;\n };\n sender?: {\n id: string;\n name: string;\n profile_url: string;\n require_auth_for_profile_image: boolean;\n };\n sqs_ts: number;\n translations: NotificationTranslations;\n type: 'ADMM' | 'MESG' | 'FILE' | string;\n unread_message_count: number;\n}\nexport interface NotificationFiles {\n type: string;\n url: string;\n name: string;\n size: number;\n require_auth: boolean;\n}\n\nexport interface NotificationTranslations {}\nexport interface NotificationMentionedUsers {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type {\n BaseChannel,\n Emoji,\n EmojiCategory,\n EmojiContainer,\n Participant,\n RestrictedUser,\n SendbirdError as SBError,\n User,\n UserUpdateParams,\n} from '@sendbird/chat';\nimport type { FeedChannel } from '@sendbird/chat/feedChannel';\nimport type {\n GroupChannel,\n GroupChannelCollection,\n GroupChannelCreateParams,\n GroupChannelListQuery,\n GroupChannelModule,\n GroupChannelUpdateParams,\n Member,\n MessageCollection,\n} from '@sendbird/chat/groupChannel';\nimport type {\n ModuleNamespaces,\n OpenChannelCreateParams,\n OpenChannelUpdateParams,\n SendableMessage,\n} from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n MessageSearchQuery,\n MultipleFilesMessage,\n PreviousMessageListQuery,\n Reaction,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelListQuery, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nexport type FilterByValueType<T extends object, Type> = {\n [K in keyof T as T[K] extends Type ? K : never]: T[K];\n};\n\nexport type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void\n ? I\n : never;\n\nexport type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];\n\nexport type PartialDeep<T> = T extends object\n ? T extends Function\n ? T\n : {\n [P in keyof T]?: PartialDeep<T[P]>;\n }\n : T;\n\nexport type PartialNullable<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport type Optional<T> = T | undefined;\n\nexport type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;\n\nexport type OnBeforeHandler<T> = (params: T) => T | Promise<T>;\n\nexport interface UserStruct {\n userId: string;\n}\n\nexport type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;\nexport type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;\nexport type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;\nexport type SendbirdUserMessage = UserMessage;\nexport type SendbirdFileMessage = FileMessage;\nexport type SendbirdMultipleFilesMessage = MultipleFilesMessage;\nexport type SendbirdAdminMessage = AdminMessage;\nexport type SendbirdBaseMessage = BaseMessage;\nexport type SendbirdSendableMessage = SendableMessage;\nexport type SendbirdFileMessageCreateParams = FileMessageCreateParams;\nexport type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;\nexport type SendbirdUserMessageCreateParams = UserMessageCreateParams;\nexport type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;\n\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdOpenChannelCreateParams = OpenChannelCreateParams;\nexport type SendbirdOpenChannelUpdateParams = OpenChannelUpdateParams;\n\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdParticipant = Participant;\n\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\nexport type SendbirdFeedChannel = FeedChannel;\n\nexport type SendbirdReaction = Reaction;\nexport type SendbirdEmoji = Emoji;\nexport type SendbirdEmojiCategory = EmojiCategory;\nexport type SendbirdEmojiContainer = EmojiContainer;\n\nexport type SendbirdGroupChannelCollection = GroupChannelCollection;\nexport type SendbirdGroupChannelListQuery = GroupChannelListQuery;\nexport type SendbirdOpenChannelListQuery = OpenChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\nexport type SendbirdMessageSearchQuery = MessageSearchQuery;\n\nexport type SendbirdError = SBError;\n\nexport interface SendbirdDataPayload {\n app_id: string;\n audience_type: string;\n category: string;\n channel: {\n channel_unread_message_count: number;\n channel_url: string;\n custom_type: string;\n name: string;\n };\n channel_type: string;\n created_at: number;\n custom_type: string;\n files: NotificationFiles[];\n mentioned_users: NotificationMentionedUsers[];\n message: string;\n message_id: number;\n push_sound: string;\n push_title: null;\n recipient: {\n id: string;\n name: string;\n push_template: string;\n };\n sender?: {\n id: string;\n name: string;\n profile_url: string;\n require_auth_for_profile_image: boolean;\n };\n sqs_ts: number;\n translations: NotificationTranslations;\n type: 'ADMM' | 'MESG' | 'FILE' | string;\n unread_message_count: number;\n}\nexport interface NotificationFiles {\n type: string;\n url: string;\n name: string;\n size: number;\n require_auth: boolean;\n}\n\nexport interface NotificationTranslations {}\nexport interface NotificationMentionedUsers {}\n"],"mappings":""}
@@ -14,7 +14,7 @@ export function isMyMessage(msg) {
14
14
  var _msg$sender;
15
15
  let currentUserId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '##__USER_ID_IS_NOT_PROVIDED__##';
16
16
  if (!isSendableMessage(msg)) return false;
17
- return 'sender' in msg && ((_msg$sender = msg.sender) === null || _msg$sender === void 0 ? void 0 : _msg$sender.userId) === currentUserId || msg.sendingStatus === 'pending' || msg.sendingStatus === 'failed' || msg.sendingStatus === 'canceled';
17
+ return ((_msg$sender = msg.sender) === null || _msg$sender === void 0 ? void 0 : _msg$sender.userId) === currentUserId;
18
18
  }
19
19
  export function messageKeyExtractor(message) {
20
20
  return getMessageUniqId(message);
@@ -31,8 +31,8 @@ export function messageKeyExtractor(message) {
31
31
  export function messageComparator(a, b) {
32
32
  let aStatusOffset = 0;
33
33
  let bStatusOffset = 0;
34
- if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;
35
- if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;
34
+ if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = Number.MAX_SAFE_INTEGER;
35
+ if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = Number.MAX_SAFE_INTEGER;
36
36
  return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);
37
37
  }
38
38
  export function hasSameSender(a, b) {
@@ -70,8 +70,15 @@ export function getMessageUniqId(msg) {
70
70
  }
71
71
  return String(msg.messageId);
72
72
  }
73
+ export function getThumbnailUriFromFileMessage(message) {
74
+ if (message.thumbnails && message.thumbnails.length > 0) {
75
+ return message.thumbnails[0].url;
76
+ }
77
+ return getAvailableUriFromFileMessage(message);
78
+ }
73
79
  export function getAvailableUriFromFileMessage(message) {
74
- if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {
80
+ var _message$messageParam;
81
+ if (!message.url && (_message$messageParam = message.messageParams) !== null && _message$messageParam !== void 0 && _message$messageParam.file && 'uri' in message.messageParams.file) {
75
82
  return message.messageParams.file.uri;
76
83
  }
77
84
  return message.url;
@@ -83,6 +90,10 @@ export function isSendbirdNotification(dataPayload) {
83
90
  export function parseSendbirdNotification(dataPayload) {
84
91
  return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;
85
92
  }
93
+ export function shouldRenderParentMessage(message) {
94
+ var _message$parentMessag, _message$parentMessag2;
95
+ return !!((message.isFileMessage() || message.isUserMessage()) && ((_message$parentMessag = message.parentMessage) !== null && _message$parentMessag !== void 0 && _message$parentMessag.isFileMessage() || (_message$parentMessag2 = message.parentMessage) !== null && _message$parentMessag2 !== void 0 && _message$parentMessag2.isUserMessage()));
96
+ }
86
97
  export function shouldRenderReaction(channel, reactionEnabled) {
87
98
  if (channel.isOpenChannel()) {
88
99
  return false;
@@ -97,9 +108,45 @@ export function shouldRenderReaction(channel, reactionEnabled) {
97
108
  export function getReactionCount(reaction) {
98
109
  return reaction.userIds.length;
99
110
  }
111
+ const fileIconMapper = {
112
+ 'audio': 'file-audio',
113
+ 'image': 'photo',
114
+ 'video': 'play',
115
+ 'file': 'file-document'
116
+ };
100
117
  export function getFileTypeFromMessage(message) {
101
118
  return getFileType(message.type || getFileExtension(message.name));
102
119
  }
120
+ export const convertFileTypeToMessageType = function () {
121
+ let fileType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'file';
122
+ switch (fileType) {
123
+ case 'audio':
124
+ case 'image':
125
+ case 'video':
126
+ return `file.${fileType}`;
127
+ case 'file':
128
+ return fileType;
129
+ }
130
+ };
131
+ export const getFileIconFromMessageType = messageType => {
132
+ switch (messageType) {
133
+ case 'file':
134
+ return fileIconMapper['file'];
135
+ case 'file.image':
136
+ return fileIconMapper['image'];
137
+ case 'file.video':
138
+ return fileIconMapper['video'];
139
+ case 'file.audio':
140
+ return fileIconMapper['audio'];
141
+ default:
142
+ return fileIconMapper['file'];
143
+ }
144
+ };
145
+ export const getFileIconFromMessage = message => {
146
+ const fileType = getFileTypeFromMessage(message);
147
+ const messageType = convertFileTypeToMessageType(fileType);
148
+ return getFileIconFromMessageType(messageType);
149
+ };
103
150
  export function getMessageType(message) {
104
151
  if (message.isAdminMessage()) {
105
152
  return 'admin';
@@ -1 +1 @@
1
- {"version":3,"names":["MessageSearchOrder","getFileExtension","getFileType","getMessageTimeFormat","isNewMessage","msg","currentUserId","myMessage","isMyMessage","isAdminMessage","updatedAt","isSendableMessage","undefined","_msg$sender","arguments","length","sender","userId","sendingStatus","messageKeyExtractor","message","getMessageUniqId","messageComparator","a","b","aStatusOffset","bStatusOffset","createdAt","hasSameSender","_a$sender","_b$sender","calcMessageGrouping","groupEnabled","curr","prev","next","getPrev","Date","getNext","groupWithPrev","groupWithNext","isUserMessage","isFileMessage","String","messageId","reqId","getAvailableUriFromFileMessage","url","messageParams","file","uri","isSendbirdNotification","dataPayload","Boolean","parseSendbirdNotification","sendbird","JSON","parse","shouldRenderReaction","channel","reactionEnabled","isOpenChannel","isGroupChannel","isBroadcast","isSuper","isEphemeral","getReactionCount","reaction","userIds","getFileTypeFromMessage","type","name","getMessageType","ogMetaData","fileType","getDefaultMessageSearchQueryParams","keyword","channelUrl","messageTimestampFrom","Math","max","joinedAt","invitedAt","order","TIMESTAMP"],"sources":["message.ts"],"sourcesContent":["import { MessageSearchOrder } from '@sendbird/chat/message';\n\nimport { getFileExtension, getFileType } from '../shared/file';\nimport type {\n SendbirdBaseChannel,\n SendbirdBaseMessage,\n SendbirdDataPayload,\n SendbirdFileMessage,\n SendbirdGroupChannel,\n SendbirdMessage,\n SendbirdReaction,\n SendbirdSendableMessage,\n} from '../types';\nimport { getMessageTimeFormat } from '../ui-format/common';\n\nexport function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {\n const myMessage = isMyMessage(msg, currentUserId);\n if (myMessage) return false;\n if (msg.isAdminMessage()) return false;\n return msg.updatedAt === 0;\n}\n\nexport function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage {\n return msg !== undefined && msg !== null && 'sendingStatus' in msg;\n}\n\nexport function isMyMessage(msg?: SendbirdMessage | null, currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##') {\n if (!isSendableMessage(msg)) return false;\n return (\n ('sender' in msg && msg.sender?.userId === currentUserId) ||\n msg.sendingStatus === 'pending' ||\n msg.sendingStatus === 'failed' ||\n msg.sendingStatus === 'canceled'\n );\n}\n\nexport function messageKeyExtractor(message: SendbirdMessage): string {\n return getMessageUniqId(message);\n}\n\n// |-------------------|-------------------|-----------------|-------------------|\n// | sending status | reqId | messageId | createdAt |\n// |-------------------|-------------------|-----------------|-------------------|\n// | pending | timestamp(A) | 0 | timestamp(B) |\n// | canceled | timestamp(A) | 0 | ? |\n// | failed | timestamp(A) | 0 | ? |\n// | succeeded | timestamp(A) / '' | id from DB | timestamp(C) |\n// |-------------------|-------------------|-----------------|-------------------|\nexport function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {\n let aStatusOffset = 0;\n let bStatusOffset = 0;\n\n if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;\n if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;\n\n return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);\n}\n\nexport function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage) {\n if (!a || !b) return false;\n if ('sender' in a && 'sender' in b) return a.sender?.userId === b.sender?.userId;\n return false;\n}\n\nexport function calcMessageGrouping(\n groupEnabled: boolean,\n curr: SendbirdMessage,\n prev?: SendbirdMessage,\n next?: SendbirdMessage,\n) {\n const getPrev = () => {\n if (!groupEnabled) return false;\n if (!prev) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, prev)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(prev.createdAt))) return false;\n return true;\n };\n\n const getNext = () => {\n if (!groupEnabled) return false;\n if (!next) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, next)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(next.createdAt))) return false;\n return true;\n };\n\n return { groupWithPrev: getPrev(), groupWithNext: getNext() };\n}\n\nexport function getMessageUniqId(msg: SendbirdBaseMessage) {\n if (msg.isUserMessage() || msg.isFileMessage()) {\n if (msg.sendingStatus === 'succeeded') return String(msg.messageId);\n return msg.reqId;\n }\n\n return String(msg.messageId);\n}\n\nexport function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {\n if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {\n return message.messageParams.file.uri;\n }\n return message.url;\n}\n\ntype RawSendbirdDataPayload = { sendbird: string | object };\nexport function isSendbirdNotification(dataPayload?: {\n [key: string]: string | object;\n}): dataPayload is RawSendbirdDataPayload {\n if (!dataPayload) return false;\n return Boolean(dataPayload['sendbird']);\n}\n\nexport function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload {\n return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;\n}\n\nexport function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean) {\n if (channel.isOpenChannel()) {\n return false;\n }\n\n if (channel.isGroupChannel()) {\n if (channel.isBroadcast) return false;\n if (channel.isSuper) return false;\n if (channel.isEphemeral) return false;\n }\n\n return reactionEnabled;\n}\n\nexport function getReactionCount(reaction: SendbirdReaction) {\n return reaction.userIds.length;\n}\n\ntype MessageType =\n | 'user'\n | 'admin'\n | 'file'\n | 'unknown'\n | `user.${'opengraph'}`\n | `file.${'image' | 'video' | 'audio'}`;\n\nexport function getFileTypeFromMessage(message: SendbirdFileMessage) {\n return getFileType(message.type || getFileExtension(message.name));\n}\n\nexport function getMessageType(message: SendbirdMessage): MessageType {\n if (message.isAdminMessage()) {\n return 'admin';\n }\n\n if (message.isUserMessage()) {\n if (message.ogMetaData) {\n return 'user.opengraph';\n }\n return 'user';\n }\n\n if (message.isFileMessage()) {\n const fileType = getFileTypeFromMessage(message);\n switch (fileType) {\n case 'image':\n case 'video': {\n return `file.${fileType}`;\n }\n case 'audio': {\n return `file.${fileType}`;\n }\n default: {\n return 'file';\n }\n }\n }\n\n return 'unknown';\n}\n\nexport function getDefaultMessageSearchQueryParams(channel: SendbirdGroupChannel, keyword: string) {\n return {\n keyword,\n channelUrl: channel.url,\n messageTimestampFrom: Math.max(channel.joinedAt, channel.invitedAt),\n order: MessageSearchOrder.TIMESTAMP,\n };\n}\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,wBAAwB;AAE3D,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,gBAAgB;AAW9D,SAASC,oBAAoB,QAAQ,qBAAqB;AAE1D,OAAO,SAASC,YAAYA,CAACC,GAAoB,EAAEC,aAAsB,EAAE;EACzE,MAAMC,SAAS,GAAGC,WAAW,CAACH,GAAG,EAAEC,aAAa,CAAC;EACjD,IAAIC,SAAS,EAAE,OAAO,KAAK;EAC3B,IAAIF,GAAG,CAACI,cAAc,EAAE,EAAE,OAAO,KAAK;EACtC,OAAOJ,GAAG,CAACK,SAAS,KAAK,CAAC;AAC5B;AAEA,OAAO,SAASC,iBAAiBA,CAACN,GAA4B,EAAkC;EAC9F,OAAOA,GAAG,KAAKO,SAAS,IAAIP,GAAG,KAAK,IAAI,IAAI,eAAe,IAAIA,GAAG;AACpE;AAEA,OAAO,SAASG,WAAWA,CAACH,GAA4B,EAAqD;EAAA,IAAAQ,WAAA;EAAA,IAAnDP,aAAa,GAAAQ,SAAA,CAAAC,MAAA,QAAAD,SAAA,Q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ACvC;EAEA,OAAOL,eAAe;AACxB;AAEA,OAAO,SAASM,gBAAgBA,CAACC,QAA0B,EAAE;EAC3D,OAAOA,QAAQ,CAACC,OAAO,CAACrD,MAAM;AAChC;AAUA,OAAO,SAASsD,sBAAsBA,CAACjD,OAA4B,EAAE;EACnE,OAAOlB,WAAW,CAACkB,OAAO,CAACkD,IAAI,IAAIrE,gBAAgB,CAACmB,OAAO,CAACmD,IAAI,CAAC,CAAC;AACpE;AAEA,OAAO,SAASC,cAAcA,CAACpD,OAAwB,EAAe;EACpE,IAAIA,OAAO,CAACX,cAAc,EAAE,EAAE;IAC5B,OAAO,OAAO;EAChB;EAEA,IAAIW,OAAO,CAACqB,aAAa,EAAE,EAAE;IAC3B,IAAIrB,OAAO,CAACqD,UAAU,EAAE;MACtB,OAAO,gBAAgB;IACzB;IACA,OAAO,MAAM;EACf;EAEA,IAAIrD,OAAO,CAACsB,aAAa,EAAE,EAAE;IAC3B,MAAMgC,QAAQ,GAAGL,sBAAsB,CAACjD,OAAO,CAAC;IAChD,QAAQsD,QAAQ;MACd,KAAK,OAAO;MACZ,KAAK,OAAO;QAAE;UACZ,OAAQ,QAAOA,QAAS,EAAC;QAC3B;MACA,KAAK,OAAO;QAAE;UACZ,OAAQ,QAAOA,QAAS,EAAC;QAC3B;MACA;QAAS;UACP,OAAO,MAAM;QACf;IAAC;EAEL;EAEA,OAAO,SAAS;AAClB;AAEA,OAAO,SAASC,kCAAkCA,CAAChB,OAA6B,EAAEiB,OAAe,EAAE;EACjG,OAAO;IACLA,OAAO;IACPC,UAAU,EAAElB,OAAO,CAACZ,GAAG;IACvB+B,oBAAoB,EAAEC,IAAI,CAACC,GAAG,CAACrB,OAAO,CAACsB,QAAQ,EAAEtB,OAAO,CAACuB,SAAS,CAAC;IACnEC,KAAK,EAAEnF,kBAAkB,CAACoF;EAC5B,CAAC;AACH"}
1
+ {"version":3,"names":["MessageSearchOrder","getFileExtension","getFileType","getMessageTimeFormat","isNewMessage","msg","currentUserId","myMessage","isMyMessage","isAdminMessage","updatedAt","isSendableMessage","undefined","_msg$sender","arguments","length","sender","userId","messageKeyExtractor","message","getMessageUniqId","messageComparator","a","b","aStatusOffset","bStatusOffset","sendingStatus","Number","MAX_SAFE_INTEGER","createdAt","hasSameSender","_a$sender","_b$sender","calcMessageGrouping","groupEnabled","curr","prev","next","getPrev","Date","getNext","groupWithPrev","groupWithNext","isUserMessage","isFileMessage","String","messageId","reqId","getThumbnailUriFromFileMessage","thumbnails","url","getAvailableUriFromFileMessage","_message$messageParam","messageParams","file","uri","isSendbirdNotification","dataPayload","Boolean","parseSendbirdNotification","sendbird","JSON","parse","shouldRenderParentMessage","_message$parentMessag","_message$parentMessag2","parentMessage","shouldRenderReaction","channel","reactionEnabled","isOpenChannel","isGroupChannel","isBroadcast","isSuper","isEphemeral","getReactionCount","reaction","userIds","fileIconMapper","getFileTypeFromMessage","type","name","convertFileTypeToMessageType","fileType","getFileIconFromMessageType","messageType","getFileIconFromMessage","getMessageType","ogMetaData","getDefaultMessageSearchQueryParams","keyword","channelUrl","messageTimestampFrom","Math","max","joinedAt","invitedAt","order","TIMESTAMP"],"sources":["message.ts"],"sourcesContent":["import { MessageSearchOrder } from '@sendbird/chat/message';\n\nimport { getFileExtension, getFileType } from '../shared/file';\nimport type {\n SendbirdBaseChannel,\n SendbirdBaseMessage,\n SendbirdDataPayload,\n SendbirdFileMessage,\n SendbirdGroupChannel,\n SendbirdMessage,\n SendbirdReaction,\n SendbirdSendableMessage,\n SendbirdUserMessage,\n} from '../types';\nimport { getMessageTimeFormat } from '../ui-format/common';\n\nexport function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {\n const myMessage = isMyMessage(msg, currentUserId);\n if (myMessage) return false;\n if (msg.isAdminMessage()) return false;\n return msg.updatedAt === 0;\n}\n\nexport function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage {\n return msg !== undefined && msg !== null && 'sendingStatus' in msg;\n}\n\nexport function isMyMessage(\n msg?: SendbirdMessage | null,\n currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##',\n): msg is SendbirdSendableMessage {\n if (!isSendableMessage(msg)) return false;\n return msg.sender?.userId === currentUserId;\n}\n\nexport function messageKeyExtractor(message: SendbirdMessage): string {\n return getMessageUniqId(message);\n}\n\n// |-------------------|-------------------|-----------------|-------------------|\n// | sending status | reqId | messageId | createdAt |\n// |-------------------|-------------------|-----------------|-------------------|\n// | pending | timestamp(A) | 0 | timestamp(B) |\n// | canceled | timestamp(A) | 0 | ? |\n// | failed | timestamp(A) | 0 | ? |\n// | succeeded | timestamp(A) / '' | id from DB | timestamp(C) |\n// |-------------------|-------------------|-----------------|-------------------|\nexport function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {\n let aStatusOffset = 0;\n let bStatusOffset = 0;\n\n if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = Number.MAX_SAFE_INTEGER;\n if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = Number.MAX_SAFE_INTEGER;\n\n return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);\n}\n\nexport function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage) {\n if (!a || !b) return false;\n if ('sender' in a && 'sender' in b) return a.sender?.userId === b.sender?.userId;\n return false;\n}\n\nexport function calcMessageGrouping(\n groupEnabled: boolean,\n curr: SendbirdMessage,\n prev?: SendbirdMessage,\n next?: SendbirdMessage,\n) {\n const getPrev = () => {\n if (!groupEnabled) return false;\n if (!prev) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, prev)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(prev.createdAt))) return false;\n return true;\n };\n\n const getNext = () => {\n if (!groupEnabled) return false;\n if (!next) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, next)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(next.createdAt))) return false;\n return true;\n };\n\n return { groupWithPrev: getPrev(), groupWithNext: getNext() };\n}\n\nexport function getMessageUniqId(msg: SendbirdBaseMessage) {\n if (msg.isUserMessage() || msg.isFileMessage()) {\n if (msg.sendingStatus === 'succeeded') return String(msg.messageId);\n return msg.reqId;\n }\n\n return String(msg.messageId);\n}\n\nexport function getThumbnailUriFromFileMessage(message: SendbirdFileMessage) {\n if (message.thumbnails && message.thumbnails.length > 0) {\n return message.thumbnails[0].url;\n }\n\n return getAvailableUriFromFileMessage(message);\n}\n\nexport function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {\n if (!message.url && message.messageParams?.file && 'uri' in message.messageParams.file) {\n return message.messageParams.file.uri;\n }\n\n return message.url;\n}\n\ntype RawSendbirdDataPayload = { sendbird: string | object };\nexport function isSendbirdNotification(dataPayload?: {\n [key: string]: string | object;\n}): dataPayload is RawSendbirdDataPayload {\n if (!dataPayload) return false;\n return Boolean(dataPayload['sendbird']);\n}\n\nexport function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload {\n return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;\n}\n\nexport function shouldRenderParentMessage(message: SendbirdMessage): message is (\n | SendbirdUserMessage\n | SendbirdFileMessage\n) & {\n parentMessage: SendbirdUserMessage | SendbirdFileMessage;\n} {\n return !!(\n (message.isFileMessage() || message.isUserMessage()) &&\n (message.parentMessage?.isFileMessage() || message.parentMessage?.isUserMessage())\n );\n}\n\nexport function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean) {\n if (channel.isOpenChannel()) {\n return false;\n }\n\n if (channel.isGroupChannel()) {\n if (channel.isBroadcast) return false;\n if (channel.isSuper) return false;\n if (channel.isEphemeral) return false;\n }\n\n return reactionEnabled;\n}\n\nexport function getReactionCount(reaction: SendbirdReaction) {\n return reaction.userIds.length;\n}\n\nexport type MessageType =\n | 'user'\n | 'admin'\n | 'file'\n | 'unknown'\n | `user.${'opengraph'}`\n | `file.${'image' | 'video' | 'audio'}`;\n\nexport type FileType = 'file' | 'image' | 'audio' | 'video';\n\nconst fileIconMapper = {\n 'audio': 'file-audio',\n 'image': 'photo',\n 'video': 'play',\n 'file': 'file-document',\n} as const;\n\ntype ValueOf<T> = T[keyof T];\nexport type FileIcon = ValueOf<typeof fileIconMapper>;\n\nexport function getFileTypeFromMessage(message: SendbirdFileMessage): FileType {\n return getFileType(message.type || getFileExtension(message.name));\n}\nexport const convertFileTypeToMessageType = (fileType: FileType = 'file'): MessageType => {\n switch (fileType) {\n case 'audio':\n case 'image':\n case 'video':\n return `file.${fileType}`;\n case 'file':\n return fileType;\n }\n};\nexport const getFileIconFromMessageType = (messageType: MessageType): FileIcon => {\n switch (messageType) {\n case 'file':\n return fileIconMapper['file'];\n case 'file.image':\n return fileIconMapper['image'];\n case 'file.video':\n return fileIconMapper['video'];\n case 'file.audio':\n return fileIconMapper['audio'];\n default:\n return fileIconMapper['file'];\n }\n};\nexport const getFileIconFromMessage = (message: SendbirdFileMessage): FileIcon => {\n const fileType = getFileTypeFromMessage(message);\n const messageType = convertFileTypeToMessageType(fileType);\n return getFileIconFromMessageType(messageType);\n};\n\nexport function getMessageType(message: SendbirdMessage): MessageType {\n if (message.isAdminMessage()) {\n return 'admin';\n }\n\n if (message.isUserMessage()) {\n if (message.ogMetaData) {\n return 'user.opengraph';\n }\n return 'user';\n }\n\n if (message.isFileMessage()) {\n const fileType = getFileTypeFromMessage(message);\n switch (fileType) {\n case 'image':\n case 'video': {\n return `file.${fileType}`;\n }\n case 'audio': {\n return `file.${fileType}`;\n }\n default: {\n return 'file';\n }\n }\n }\n\n return 'unknown';\n}\n\nexport function getDefaultMessageSearchQueryParams(channel: SendbirdGroupChannel, keyword: string) {\n return {\n keyword,\n channelUrl: channel.url,\n messageTimestampFrom: Math.max(channel.joinedAt, channel.invitedAt),\n order: MessageSearchOrder.TIMESTAMP,\n };\n}\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,wBAA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ACC,QAAQ,CAAC;EAC1D,OAAOC,0BAA0B,CAACC,WAAW,CAAC;AAChD,CAAC;AAED,OAAO,SAASE,cAAcA,CAACpE,OAAwB,EAAe;EACpE,IAAIA,OAAO,CAACV,cAAc,EAAE,EAAE;IAC5B,OAAO,OAAO;EAChB;EAEA,IAAIU,OAAO,CAACwB,aAAa,EAAE,EAAE;IAC3B,IAAIxB,OAAO,CAACqE,UAAU,EAAE;MACtB,OAAO,gBAAgB;IACzB;IACA,OAAO,MAAM;EACf;EAEA,IAAIrE,OAAO,CAACyB,aAAa,EAAE,EAAE;IAC3B,MAAMuC,QAAQ,GAAGJ,sBAAsB,CAAC5D,OAAO,CAAC;IAChD,QAAQgE,QAAQ;MACd,KAAK,OAAO;MACZ,KAAK,OAAO;QAAE;UACZ,OAAQ,QAAOA,QAAS,EAAC;QAC3B;MACA,KAAK,OAAO;QAAE;UACZ,OAAQ,QAAOA,QAAS,EAAC;QAC3B;MACA;QAAS;UACP,OAAO,MAAM;QACf;IAAC;EAEL;EAEA,OAAO,SAAS;AAClB;AAEA,OAAO,SAASM,kCAAkCA,CAACrB,OAA6B,EAAEsB,OAAe,EAAE;EACjG,OAAO;IACLA,OAAO;IACPC,UAAU,EAAEvB,OAAO,CAAClB,GAAG;IACvB0C,oBAAoB,EAAEC,IAAI,CAACC,GAAG,CAAC1B,OAAO,CAAC2B,QAAQ,EAAE3B,OAAO,CAAC4B,SAAS,CAAC;IACnEC,KAAK,EAAEjG,kBAAkB,CAACkG;EAC5B,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"names":["ifOperator","role","then","or","getUserUniqId","user","userId"],"sources":["user.ts"],"sourcesContent":["import type { Role } from '@sendbird/chat';\n\nimport type { UserStruct } from '../types';\n\nexport function ifOperator<T>(role: Role, then: T): T | undefined;\nexport function ifOperator<T, V>(role: Role, then: T, or: V): T | V;\nexport function ifOperator(role: Role, then: unknown, or?: unknown) {\n if (role === 'operator') return then;\n return or;\n}\n\nexport function getUserUniqId<T extends UserStruct>(user: T) {\n return user.userId;\n}\n"],"mappings":"AAMA,OAAO,SAASA,UAAUA,CAACC,IAAU,EAAEC,IAAa,EAAEC,EAAY,EAAE;EAClE,IAAIF,IAAI,KAAK,UAAU,EAAE,OAAOC,IAAI;EACpC,OAAOC,EAAE;AACX;AAEA,OAAO,SAASC,aAAaA,CAAuBC,IAAO,EAAE;EAC3D,OAAOA,IAAI,CAACC,MAAM;AACpB"}
1
+ {"version":3,"names":["ifOperator","role","then","or","getUserUniqId","user","userId"],"sources":["user.ts"],"sourcesContent":["import type { Role } from '@sendbird/chat';\n\nimport type { UserStruct } from '../types';\n\nexport function ifOperator<T>(role: Role | null, then: T): T | undefined;\nexport function ifOperator<T, V>(role: Role | null, then: T, or: V): T | V;\nexport function ifOperator(role: Role | null, then: unknown, or?: unknown) {\n if (role === 'operator') return then;\n return or;\n}\n\nexport function getUserUniqId<T extends UserStruct>(user: T) {\n return user.userId;\n}\n"],"mappings":"AAMA,OAAO,SAASA,UAAUA,CAACC,IAAiB,EAAEC,IAAa,EAAEC,EAAY,EAAE;EACzE,IAAIF,IAAI,KAAK,UAAU,EAAE,OAAOC,IAAI;EACpC,OAAOC,EAAE;AACX;AAEA,OAAO,SAASC,aAAaA,CAAuBC,IAAO,EAAE;EAC3D,OAAOA,IAAI,CAACC,MAAM;AACpB"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type {\n BaseChannel,\n Emoji,\n EmojiCategory,\n EmojiContainer,\n Participant,\n RestrictedUser,\n SendbirdError as SBError,\n User,\n UserUpdateParams,\n} from '@sendbird/chat';\nimport type {\n GroupChannel,\n GroupChannelCollection,\n GroupChannelCreateParams,\n GroupChannelListQuery,\n GroupChannelModule,\n GroupChannelUpdateParams,\n Member,\n MessageCollection,\n} from '@sendbird/chat/groupChannel';\nimport type {\n ModuleNamespaces,\n OpenChannelCreateParams,\n OpenChannelUpdateParams,\n SendableMessage,\n} from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n MessageSearchQuery,\n MultipleFilesMessage,\n PreviousMessageListQuery,\n Reaction,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelListQuery, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nexport type FilterByValueType<T extends object, Type> = {\n [K in keyof T as T[K] extends Type ? K : never]: T[K];\n};\n\nexport type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void\n ? I\n : never;\n\nexport type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];\n\nexport type PartialDeep<T> = T extends object\n ? T extends Function\n ? T\n : {\n [P in keyof T]?: PartialDeep<T[P]>;\n }\n : T;\n\nexport type PartialNullable<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport type Optional<T> = T | undefined;\n\nexport type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;\n\nexport type OnBeforeHandler<T> = (params: T) => T | Promise<T>;\n\nexport interface UserStruct {\n userId: string;\n}\n\nexport type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;\nexport type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;\nexport type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;\nexport type SendbirdUserMessage = UserMessage;\nexport type SendbirdFileMessage = FileMessage;\nexport type SendbirdMultipleFilesMessage = MultipleFilesMessage;\nexport type SendbirdAdminMessage = AdminMessage;\nexport type SendbirdBaseMessage = BaseMessage;\nexport type SendbirdSendableMessage = SendableMessage;\nexport type SendbirdFileMessageCreateParams = FileMessageCreateParams;\nexport type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;\nexport type SendbirdUserMessageCreateParams = UserMessageCreateParams;\nexport type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;\n\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdOpenChannelCreateParams = OpenChannelCreateParams;\nexport type SendbirdOpenChannelUpdateParams = OpenChannelUpdateParams;\n\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdParticipant = Participant;\n\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\n\nexport type SendbirdReaction = Reaction;\nexport type SendbirdEmoji = Emoji;\nexport type SendbirdEmojiCategory = EmojiCategory;\nexport type SendbirdEmojiContainer = EmojiContainer;\n\nexport type SendbirdGroupChannelCollection = GroupChannelCollection;\nexport type SendbirdGroupChannelListQuery = GroupChannelListQuery;\nexport type SendbirdOpenChannelListQuery = OpenChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\nexport type SendbirdMessageSearchQuery = MessageSearchQuery;\n\nexport type SendbirdError = SBError;\n\nexport interface SendbirdDataPayload {\n app_id: string;\n audience_type: string;\n category: string;\n channel: {\n channel_unread_message_count: number;\n channel_url: string;\n custom_type: string;\n name: string;\n };\n channel_type: string;\n created_at: number;\n custom_type: string;\n files: NotificationFiles[];\n mentioned_users: NotificationMentionedUsers[];\n message: string;\n message_id: number;\n push_sound: string;\n push_title: null;\n recipient: {\n id: string;\n name: string;\n push_template: string;\n };\n sender?: {\n id: string;\n name: string;\n profile_url: string;\n require_auth_for_profile_image: boolean;\n };\n sqs_ts: number;\n translations: NotificationTranslations;\n type: 'ADMM' | 'MESG' | 'FILE' | string;\n unread_message_count: number;\n}\nexport interface NotificationFiles {\n type: string;\n url: string;\n name: string;\n size: number;\n require_auth: boolean;\n}\n\nexport interface NotificationTranslations {}\nexport interface NotificationMentionedUsers {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type {\n BaseChannel,\n Emoji,\n EmojiCategory,\n EmojiContainer,\n Participant,\n RestrictedUser,\n SendbirdError as SBError,\n User,\n UserUpdateParams,\n} from '@sendbird/chat';\nimport type { FeedChannel } from '@sendbird/chat/feedChannel';\nimport type {\n GroupChannel,\n GroupChannelCollection,\n GroupChannelCreateParams,\n GroupChannelListQuery,\n GroupChannelModule,\n GroupChannelUpdateParams,\n Member,\n MessageCollection,\n} from '@sendbird/chat/groupChannel';\nimport type {\n ModuleNamespaces,\n OpenChannelCreateParams,\n OpenChannelUpdateParams,\n SendableMessage,\n} from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n MessageSearchQuery,\n MultipleFilesMessage,\n PreviousMessageListQuery,\n Reaction,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelListQuery, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nexport type FilterByValueType<T extends object, Type> = {\n [K in keyof T as T[K] extends Type ? K : never]: T[K];\n};\n\nexport type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void\n ? I\n : never;\n\nexport type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];\n\nexport type PartialDeep<T> = T extends object\n ? T extends Function\n ? T\n : {\n [P in keyof T]?: PartialDeep<T[P]>;\n }\n : T;\n\nexport type PartialNullable<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport type Optional<T> = T | undefined;\n\nexport type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;\n\nexport type OnBeforeHandler<T> = (params: T) => T | Promise<T>;\n\nexport interface UserStruct {\n userId: string;\n}\n\nexport type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;\nexport type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;\nexport type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;\nexport type SendbirdUserMessage = UserMessage;\nexport type SendbirdFileMessage = FileMessage;\nexport type SendbirdMultipleFilesMessage = MultipleFilesMessage;\nexport type SendbirdAdminMessage = AdminMessage;\nexport type SendbirdBaseMessage = BaseMessage;\nexport type SendbirdSendableMessage = SendableMessage;\nexport type SendbirdFileMessageCreateParams = FileMessageCreateParams;\nexport type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;\nexport type SendbirdUserMessageCreateParams = UserMessageCreateParams;\nexport type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;\n\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdOpenChannelCreateParams = OpenChannelCreateParams;\nexport type SendbirdOpenChannelUpdateParams = OpenChannelUpdateParams;\n\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdParticipant = Participant;\n\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\nexport type SendbirdFeedChannel = FeedChannel;\n\nexport type SendbirdReaction = Reaction;\nexport type SendbirdEmoji = Emoji;\nexport type SendbirdEmojiCategory = EmojiCategory;\nexport type SendbirdEmojiContainer = EmojiContainer;\n\nexport type SendbirdGroupChannelCollection = GroupChannelCollection;\nexport type SendbirdGroupChannelListQuery = GroupChannelListQuery;\nexport type SendbirdOpenChannelListQuery = OpenChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\nexport type SendbirdMessageSearchQuery = MessageSearchQuery;\n\nexport type SendbirdError = SBError;\n\nexport interface SendbirdDataPayload {\n app_id: string;\n audience_type: string;\n category: string;\n channel: {\n channel_unread_message_count: number;\n channel_url: string;\n custom_type: string;\n name: string;\n };\n channel_type: string;\n created_at: number;\n custom_type: string;\n files: NotificationFiles[];\n mentioned_users: NotificationMentionedUsers[];\n message: string;\n message_id: number;\n push_sound: string;\n push_title: null;\n recipient: {\n id: string;\n name: string;\n push_template: string;\n };\n sender?: {\n id: string;\n name: string;\n profile_url: string;\n require_auth_for_profile_image: boolean;\n };\n sqs_ts: number;\n translations: NotificationTranslations;\n type: 'ADMM' | 'MESG' | 'FILE' | string;\n unread_message_count: number;\n}\nexport interface NotificationFiles {\n type: string;\n url: string;\n name: string;\n size: number;\n require_auth: boolean;\n}\n\nexport interface NotificationTranslations {}\nexport interface NotificationMentionedUsers {}\n"],"mappings":""}
@@ -1,8 +1,8 @@
1
1
  import { MessageSearchOrder } from '@sendbird/chat/message';
2
- import type { SendbirdBaseChannel, SendbirdBaseMessage, SendbirdDataPayload, SendbirdFileMessage, SendbirdGroupChannel, SendbirdMessage, SendbirdReaction, SendbirdSendableMessage } from '../types';
2
+ import type { SendbirdBaseChannel, SendbirdBaseMessage, SendbirdDataPayload, SendbirdFileMessage, SendbirdGroupChannel, SendbirdMessage, SendbirdReaction, SendbirdSendableMessage, SendbirdUserMessage } from '../types';
3
3
  export declare function isNewMessage(msg: SendbirdMessage, currentUserId?: string): boolean;
4
4
  export declare function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage;
5
- export declare function isMyMessage(msg?: SendbirdMessage | null, currentUserId?: string): boolean;
5
+ export declare function isMyMessage(msg?: SendbirdMessage | null, currentUserId?: string): msg is SendbirdSendableMessage;
6
6
  export declare function messageKeyExtractor(message: SendbirdMessage): string;
7
7
  export declare function messageComparator(a: SendbirdMessage, b: SendbirdMessage): number;
8
8
  export declare function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage): boolean;
@@ -11,6 +11,7 @@ export declare function calcMessageGrouping(groupEnabled: boolean, curr: Sendbir
11
11
  groupWithNext: boolean;
12
12
  };
13
13
  export declare function getMessageUniqId(msg: SendbirdBaseMessage): string;
14
+ export declare function getThumbnailUriFromFileMessage(message: SendbirdFileMessage): string;
14
15
  export declare function getAvailableUriFromFileMessage(message: SendbirdFileMessage): string;
15
16
  type RawSendbirdDataPayload = {
16
17
  sendbird: string | object;
@@ -19,10 +20,25 @@ export declare function isSendbirdNotification(dataPayload?: {
19
20
  [key: string]: string | object;
20
21
  }): dataPayload is RawSendbirdDataPayload;
21
22
  export declare function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload;
23
+ export declare function shouldRenderParentMessage(message: SendbirdMessage): message is (SendbirdUserMessage | SendbirdFileMessage) & {
24
+ parentMessage: SendbirdUserMessage | SendbirdFileMessage;
25
+ };
22
26
  export declare function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean): boolean;
23
27
  export declare function getReactionCount(reaction: SendbirdReaction): number;
24
- type MessageType = 'user' | 'admin' | 'file' | 'unknown' | `user.${'opengraph'}` | `file.${'image' | 'video' | 'audio'}`;
25
- export declare function getFileTypeFromMessage(message: SendbirdFileMessage): "video" | "audio" | "image" | "file";
28
+ export type MessageType = 'user' | 'admin' | 'file' | 'unknown' | `user.${'opengraph'}` | `file.${'image' | 'video' | 'audio'}`;
29
+ export type FileType = 'file' | 'image' | 'audio' | 'video';
30
+ declare const fileIconMapper: {
31
+ readonly audio: "file-audio";
32
+ readonly image: "photo";
33
+ readonly video: "play";
34
+ readonly file: "file-document";
35
+ };
36
+ type ValueOf<T> = T[keyof T];
37
+ export type FileIcon = ValueOf<typeof fileIconMapper>;
38
+ export declare function getFileTypeFromMessage(message: SendbirdFileMessage): FileType;
39
+ export declare const convertFileTypeToMessageType: (fileType?: FileType) => MessageType;
40
+ export declare const getFileIconFromMessageType: (messageType: MessageType) => FileIcon;
41
+ export declare const getFileIconFromMessage: (message: SendbirdFileMessage) => FileIcon;
26
42
  export declare function getMessageType(message: SendbirdMessage): MessageType;
27
43
  export declare function getDefaultMessageSearchQueryParams(channel: SendbirdGroupChannel, keyword: string): {
28
44
  keyword: string;
@@ -1,5 +1,5 @@
1
1
  import type { Role } from '@sendbird/chat';
2
2
  import type { UserStruct } from '../types';
3
- export declare function ifOperator<T>(role: Role, then: T): T | undefined;
4
- export declare function ifOperator<T, V>(role: Role, then: T, or: V): T | V;
3
+ export declare function ifOperator<T>(role: Role | null, then: T): T | undefined;
4
+ export declare function ifOperator<T, V>(role: Role | null, then: T, or: V): T | V;
5
5
  export declare function getUserUniqId<T extends UserStruct>(user: T): string;
@@ -1,6 +1,7 @@
1
1
  import type React from 'react';
2
2
  import type SendbirdChat from '@sendbird/chat';
3
3
  import type { BaseChannel, Emoji, EmojiCategory, EmojiContainer, Participant, RestrictedUser, SendbirdError as SBError, User, UserUpdateParams } from '@sendbird/chat';
4
+ import type { FeedChannel } from '@sendbird/chat/feedChannel';
4
5
  import type { GroupChannel, GroupChannelCollection, GroupChannelCreateParams, GroupChannelListQuery, GroupChannelModule, GroupChannelUpdateParams, Member, MessageCollection } from '@sendbird/chat/groupChannel';
5
6
  import type { ModuleNamespaces, OpenChannelCreateParams, OpenChannelUpdateParams, SendableMessage } from '@sendbird/chat/lib/__definition';
6
7
  import type { AdminMessage, BaseMessage, FileMessage, FileMessageCreateParams, FileMessageUpdateParams, MessageSearchQuery, MultipleFilesMessage, PreviousMessageListQuery, Reaction, UserMessage, UserMessageCreateParams, UserMessageUpdateParams } from '@sendbird/chat/message';
@@ -47,6 +48,7 @@ export type SendbirdParticipant = Participant;
47
48
  export type SendbirdGroupChannel = GroupChannel;
48
49
  export type SendbirdBaseChannel = BaseChannel;
49
50
  export type SendbirdOpenChannel = OpenChannel;
51
+ export type SendbirdFeedChannel = FeedChannel;
50
52
  export type SendbirdReaction = Reaction;
51
53
  export type SendbirdEmoji = Emoji;
52
54
  export type SendbirdEmojiCategory = EmojiCategory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendbird/uikit-utils",
3
- "version": "3.0.4",
3
+ "version": "3.1.1",
4
4
  "description": "A collection of utility functions and constants for building chat UI components with Sendbird UIKit.",
5
5
  "keywords": [
6
6
  "sendbird",
@@ -55,7 +55,7 @@
55
55
  "typescript": "4.9.4"
56
56
  },
57
57
  "peerDependencies": {
58
- "@sendbird/chat": "^4.9.2",
58
+ "@sendbird/chat": "^4.9.8",
59
59
  "react": ">=17.0.2",
60
60
  "react-native": ">=0.65.0"
61
61
  },
@@ -86,5 +86,5 @@
86
86
  "readmeFile": "./README.md",
87
87
  "displayName": "@sendbird/uikit-utils"
88
88
  },
89
- "gitHead": "bf8ff3723f82f75ccf994938d6e5468e6fb669be"
89
+ "gitHead": "cc1e2d626a4a3278e80d523b4c63fd3719c82441"
90
90
  }
@@ -10,6 +10,7 @@ import type {
10
10
  SendbirdMessage,
11
11
  SendbirdReaction,
12
12
  SendbirdSendableMessage,
13
+ SendbirdUserMessage,
13
14
  } from '../types';
14
15
  import { getMessageTimeFormat } from '../ui-format/common';
15
16
 
@@ -24,14 +25,12 @@ export function isSendableMessage(msg?: SendbirdMessage | null): msg is Sendbird
24
25
  return msg !== undefined && msg !== null && 'sendingStatus' in msg;
25
26
  }
26
27
 
27
- export function isMyMessage(msg?: SendbirdMessage | null, currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##') {
28
+ export function isMyMessage(
29
+ msg?: SendbirdMessage | null,
30
+ currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##',
31
+ ): msg is SendbirdSendableMessage {
28
32
  if (!isSendableMessage(msg)) return false;
29
- return (
30
- ('sender' in msg && msg.sender?.userId === currentUserId) ||
31
- msg.sendingStatus === 'pending' ||
32
- msg.sendingStatus === 'failed' ||
33
- msg.sendingStatus === 'canceled'
34
- );
33
+ return msg.sender?.userId === currentUserId;
35
34
  }
36
35
 
37
36
  export function messageKeyExtractor(message: SendbirdMessage): string {
@@ -50,8 +49,8 @@ export function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {
50
49
  let aStatusOffset = 0;
51
50
  let bStatusOffset = 0;
52
51
 
53
- if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;
54
- if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;
52
+ if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = Number.MAX_SAFE_INTEGER;
53
+ if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = Number.MAX_SAFE_INTEGER;
55
54
 
56
55
  return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);
57
56
  }
@@ -98,10 +97,19 @@ export function getMessageUniqId(msg: SendbirdBaseMessage) {
98
97
  return String(msg.messageId);
99
98
  }
100
99
 
100
+ export function getThumbnailUriFromFileMessage(message: SendbirdFileMessage) {
101
+ if (message.thumbnails && message.thumbnails.length > 0) {
102
+ return message.thumbnails[0].url;
103
+ }
104
+
105
+ return getAvailableUriFromFileMessage(message);
106
+ }
107
+
101
108
  export function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {
102
- if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {
109
+ if (!message.url && message.messageParams?.file && 'uri' in message.messageParams.file) {
103
110
  return message.messageParams.file.uri;
104
111
  }
112
+
105
113
  return message.url;
106
114
  }
107
115
 
@@ -117,6 +125,18 @@ export function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload):
117
125
  return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;
118
126
  }
119
127
 
128
+ export function shouldRenderParentMessage(message: SendbirdMessage): message is (
129
+ | SendbirdUserMessage
130
+ | SendbirdFileMessage
131
+ ) & {
132
+ parentMessage: SendbirdUserMessage | SendbirdFileMessage;
133
+ } {
134
+ return !!(
135
+ (message.isFileMessage() || message.isUserMessage()) &&
136
+ (message.parentMessage?.isFileMessage() || message.parentMessage?.isUserMessage())
137
+ );
138
+ }
139
+
120
140
  export function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean) {
121
141
  if (channel.isOpenChannel()) {
122
142
  return false;
@@ -135,7 +155,7 @@ export function getReactionCount(reaction: SendbirdReaction) {
135
155
  return reaction.userIds.length;
136
156
  }
137
157
 
138
- type MessageType =
158
+ export type MessageType =
139
159
  | 'user'
140
160
  | 'admin'
141
161
  | 'file'
@@ -143,9 +163,50 @@ type MessageType =
143
163
  | `user.${'opengraph'}`
144
164
  | `file.${'image' | 'video' | 'audio'}`;
145
165
 
146
- export function getFileTypeFromMessage(message: SendbirdFileMessage) {
166
+ export type FileType = 'file' | 'image' | 'audio' | 'video';
167
+
168
+ const fileIconMapper = {
169
+ 'audio': 'file-audio',
170
+ 'image': 'photo',
171
+ 'video': 'play',
172
+ 'file': 'file-document',
173
+ } as const;
174
+
175
+ type ValueOf<T> = T[keyof T];
176
+ export type FileIcon = ValueOf<typeof fileIconMapper>;
177
+
178
+ export function getFileTypeFromMessage(message: SendbirdFileMessage): FileType {
147
179
  return getFileType(message.type || getFileExtension(message.name));
148
180
  }
181
+ export const convertFileTypeToMessageType = (fileType: FileType = 'file'): MessageType => {
182
+ switch (fileType) {
183
+ case 'audio':
184
+ case 'image':
185
+ case 'video':
186
+ return `file.${fileType}`;
187
+ case 'file':
188
+ return fileType;
189
+ }
190
+ };
191
+ export const getFileIconFromMessageType = (messageType: MessageType): FileIcon => {
192
+ switch (messageType) {
193
+ case 'file':
194
+ return fileIconMapper['file'];
195
+ case 'file.image':
196
+ return fileIconMapper['image'];
197
+ case 'file.video':
198
+ return fileIconMapper['video'];
199
+ case 'file.audio':
200
+ return fileIconMapper['audio'];
201
+ default:
202
+ return fileIconMapper['file'];
203
+ }
204
+ };
205
+ export const getFileIconFromMessage = (message: SendbirdFileMessage): FileIcon => {
206
+ const fileType = getFileTypeFromMessage(message);
207
+ const messageType = convertFileTypeToMessageType(fileType);
208
+ return getFileIconFromMessageType(messageType);
209
+ };
149
210
 
150
211
  export function getMessageType(message: SendbirdMessage): MessageType {
151
212
  if (message.isAdminMessage()) {
@@ -2,9 +2,9 @@ import type { Role } from '@sendbird/chat';
2
2
 
3
3
  import type { UserStruct } from '../types';
4
4
 
5
- export function ifOperator<T>(role: Role, then: T): T | undefined;
6
- export function ifOperator<T, V>(role: Role, then: T, or: V): T | V;
7
- export function ifOperator(role: Role, then: unknown, or?: unknown) {
5
+ export function ifOperator<T>(role: Role | null, then: T): T | undefined;
6
+ export function ifOperator<T, V>(role: Role | null, then: T, or: V): T | V;
7
+ export function ifOperator(role: Role | null, then: unknown, or?: unknown) {
8
8
  if (role === 'operator') return then;
9
9
  return or;
10
10
  }
package/src/types.ts CHANGED
@@ -15,6 +15,7 @@ import type {
15
15
  User,
16
16
  UserUpdateParams,
17
17
  } from '@sendbird/chat';
18
+ import type { FeedChannel } from '@sendbird/chat/feedChannel';
18
19
  import type {
19
20
  GroupChannel,
20
21
  GroupChannelCollection,
@@ -107,6 +108,7 @@ export type SendbirdParticipant = Participant;
107
108
  export type SendbirdGroupChannel = GroupChannel;
108
109
  export type SendbirdBaseChannel = BaseChannel;
109
110
  export type SendbirdOpenChannel = OpenChannel;
111
+ export type SendbirdFeedChannel = FeedChannel;
110
112
 
111
113
  export type SendbirdReaction = Reaction;
112
114
  export type SendbirdEmoji = Emoji;