@tencentcloud/chat-uikit-react 1.0.1 → 1.0.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/CHANGELOG.md +10 -0
- package/README.md +34 -84
- package/dist/cjs/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
- package/dist/cjs/components/ConversationPreview/utils.js +1 -1
- package/dist/cjs/components/ConversationSearch/ConversationSearchResult.js +1 -1
- package/dist/cjs/components/Icon/images/union.png.js +1 -1
- package/dist/cjs/components/Icon/images/ununion.png.js +1 -1
- package/dist/cjs/components/TUIChat/TUIChat.js +1 -1
- package/dist/cjs/components/TUIChat/hooks/useCreateMessage.js +1 -1
- package/dist/cjs/components/TUIChat/hooks/useMessageReceviedListener.js +1 -1
- package/dist/cjs/components/TUIChat/unitls.js +1 -1
- package/dist/cjs/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
- package/dist/cjs/components/TUIConversation/TUIConversation.d.ts +2 -0
- package/dist/cjs/components/TUIConversation/TUIConversation.js +1 -1
- package/dist/cjs/components/TUIConversationList/TUIConversationList.d.ts +1 -0
- package/dist/cjs/components/TUIConversationList/TUIConversationList.js +1 -1
- package/dist/cjs/components/TUIConversationList/hooks/useConversationList.js +1 -1
- package/dist/cjs/components/TUIConversationList/hooks/useConversationUpdate.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageBubble.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageContext.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageCustom.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageFile.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageImage.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageMerger.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageName.js +1 -1
- package/dist/cjs/components/TUIMessage/MessagePlugins.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageProgress.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageRevoke.js +1 -1
- package/dist/cjs/components/TUIMessage/MessageText.js +1 -1
- package/dist/cjs/components/TUIMessage/TUIMessage.js +1 -1
- package/dist/cjs/components/TUIMessage/TUIMessageDefault.js +1 -1
- package/dist/cjs/components/TUIMessage/hooks/useMessageContextHandler.js +1 -1
- package/dist/cjs/components/TUIMessage/hooks/useMessageReply.js +1 -1
- package/dist/cjs/components/TUIMessage/utils/index.js +1 -1
- package/dist/cjs/components/TUIMessageInput/InputQuoteDefalut.js +1 -1
- package/dist/cjs/components/TUIMessageInput/TUIMessageInput.js +1 -1
- package/dist/cjs/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
- package/dist/cjs/components/TUIMessageInput/hooks/useHandleQuoteMessage.js +1 -1
- package/dist/cjs/components/TUIMessageList/TUIMessageList.js +1 -1
- package/dist/cjs/components/TUIProfile/TUIProfileDefault.js +1 -1
- package/dist/cjs/components/TUIProfile/hooks/useMyProfile.js +1 -1
- package/dist/cjs/components/untils.js +1 -1
- package/dist/cjs/context/TUIConversationContext.js +1 -1
- package/dist/cjs/hooks/useConversation.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/ConversationCreate/hooks/useConversationCreate.js +1 -1
- package/dist/esm/components/ConversationPreview/utils.js +1 -1
- package/dist/esm/components/ConversationSearch/ConversationSearchResult.js +1 -1
- package/dist/esm/components/Icon/images/union.png.js +1 -1
- package/dist/esm/components/Icon/images/ununion.png.js +1 -1
- package/dist/esm/components/TUIChat/TUIChat.js +1 -1
- package/dist/esm/components/TUIChat/hooks/useCreateMessage.js +1 -1
- package/dist/esm/components/TUIChat/hooks/useMessageReceviedListener.js +1 -1
- package/dist/esm/components/TUIChat/unitls.js +1 -1
- package/dist/esm/components/TUIChatHeader/TUIChatHeaderDefault.js +1 -1
- package/dist/esm/components/TUIConversation/TUIConversation.d.ts +2 -0
- package/dist/esm/components/TUIConversation/TUIConversation.js +1 -1
- package/dist/esm/components/TUIConversationList/TUIConversationList.d.ts +1 -0
- package/dist/esm/components/TUIConversationList/TUIConversationList.js +1 -1
- package/dist/esm/components/TUIConversationList/hooks/useConversationList.js +1 -1
- package/dist/esm/components/TUIConversationList/hooks/useConversationUpdate.js +1 -1
- package/dist/esm/components/TUIMessage/MessageBubble.js +1 -1
- package/dist/esm/components/TUIMessage/MessageContext.js +1 -1
- package/dist/esm/components/TUIMessage/MessageCustom.js +1 -1
- package/dist/esm/components/TUIMessage/MessageFile.js +1 -1
- package/dist/esm/components/TUIMessage/MessageImage.js +1 -1
- package/dist/esm/components/TUIMessage/MessageMerger.js +1 -1
- package/dist/esm/components/TUIMessage/MessageName.js +1 -1
- package/dist/esm/components/TUIMessage/MessagePlugins.js +1 -1
- package/dist/esm/components/TUIMessage/MessageProgress.js +1 -1
- package/dist/esm/components/TUIMessage/MessageRevoke.js +1 -1
- package/dist/esm/components/TUIMessage/MessageText.js +1 -1
- package/dist/esm/components/TUIMessage/TUIMessage.js +1 -1
- package/dist/esm/components/TUIMessage/TUIMessageDefault.js +1 -1
- package/dist/esm/components/TUIMessage/hooks/useMessageContextHandler.js +1 -1
- package/dist/esm/components/TUIMessage/hooks/useMessageReply.js +1 -1
- package/dist/esm/components/TUIMessage/utils/index.js +1 -1
- package/dist/esm/components/TUIMessageInput/InputQuoteDefalut.js +1 -1
- package/dist/esm/components/TUIMessageInput/TUIMessageInput.js +1 -1
- package/dist/esm/components/TUIMessageInput/hooks/useHandleForwardMessage.js +1 -1
- package/dist/esm/components/TUIMessageInput/hooks/useHandleQuoteMessage.js +1 -1
- package/dist/esm/components/TUIMessageList/TUIMessageList.js +1 -1
- package/dist/esm/components/TUIProfile/TUIProfileDefault.js +1 -1
- package/dist/esm/components/TUIProfile/hooks/useMyProfile.js +1 -1
- package/dist/esm/components/untils.js +1 -1
- package/dist/esm/context/TUIConversationContext.js +1 -1
- package/dist/esm/hooks/useConversation.js +1 -1
- package/dist/esm/index.js +1 -1
- package/package.json +2 -1
- package/readme.zh_cn.md +60 -0
- package/src/components/ConversationPreview/utils.tsx +2 -1
- package/src/components/Icon/images/union.png +0 -0
- package/src/components/Icon/images/ununion.png +0 -0
- package/src/components/TUIConversation/TUIConversation.tsx +5 -0
- package/src/components/TUIConversationList/TUIConversationList.tsx +14 -2
- package/src/components/TUIConversationList/hooks/useConversationList.tsx +9 -3
- package/src/components/TUIConversationList/hooks/useConversationUpdate.tsx +8 -3
- package/src/components/TUIMessage/utils/index.ts +3 -0
- package/src/components/TUIMessageInput/InputQuoteDefalut.tsx +3 -3
- package/src/components/TUIMessageInput/hooks/useHandleQuoteMessage.tsx +1 -0
- package/src/components/TUIMessageList/TUIMessageList.tsx +1 -1
- package/src/components/untils.ts +10 -12
- package/src/context/TUIConversationContext.tsx +2 -0
- package/dist/cjs/_virtual/_commonjsHelpers.js +0 -1
- package/dist/cjs/_virtual/tim-js.js +0 -1
- package/dist/esm/_virtual/_commonjsHelpers.js +0 -1
- package/dist/esm/_virtual/tim-js.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as r,jsxs as t}from"react/jsx-runtime";import
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as r,jsxs as t}from"react/jsx-runtime";import i from"react";import m from"tim-js-sdk";function s(i){var s=i.context,a=i.message,n=i.children;return t("div",e({className:"bubble message-merger bubble-".concat(a.flow," ").concat((null==a?void 0:a.conversationType)===m.TYPES.CONV_GROUP?"group":"")},{children:[r("h3",{children:s.title}),r("ul",e({className:"message-merger-list"},{children:(null==s?void 0:s.abstractList.length)>0&&s.abstractList.map((function(t,i){var m=t+i;return r("li",e({className:"message-merger-item"},{children:t}),m)}))})),n]}))}var a=i.memo(s);function n(t){return r(a,e({},t))}export{n as MessageMerger};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as o}from"tslib";import{jsx as
|
|
1
|
+
import{__assign as o}from"tslib";import{jsx as t}from"react/jsx-runtime";import e from"tim-js-sdk";import"react";import{messageShowType as r}from"../../context/TUIMessageContext.js";function m(m){m.className;var l=m.CustomName,n=m.message,i=m.showType;return(i===r.ALL||(null==n?void 0:n.flow)===i)&&(null==n?void 0:n.conversationType)===e.TYPES.CONV_GROUP&&i!==r.NONE?l||t("label",o({htmlFor:"content",className:"name"},{children:(null==n?void 0:n.nick)||(null==n?void 0:n.from)})):null}export{m as MessageName};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsxs as s,jsx as o}from"react/jsx-runtime";import{useState as l,useRef as i}from"react";import n from"
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as s,jsx as o}from"react/jsx-runtime";import{useState as l,useRef as i}from"react";import n from"tim-js-sdk";import{Plugins as t}from"../Plugins/index.js";import{Icon as r}from"../Icon/Icon.js";import{IconTypes as a}from"../Icon/type.js";import{useTUIChatStateContext as d}from"../../context/TUIChatStateContext.js";import{useTUIMessageContext as u}from"../../context/TUIMessageContext.js";import{useMessageHandler as c}from"./hooks/useMessageHandler.js";import{MESSAGE_STATUS as h,MESSAGE_FLOW as g}from"../../constants.js";import"date-fns";import{useMessagePluginElement as m}from"./hooks/useMessagePluginElement.js";var p;function v(p){var v,f,S,w,M,y,C=p.plugins,T=p.showNumber,E=p.MoreIcon,N=p.config,k=l(""),R=k[0],U=k[1],j=i(null),I=u("MessagePlugins"),x=I.message,b=I.plugin,q=d("MessageBubbleWithContext").messageListRef,O=c({message:x}),P=O.handleDelMessage,D=O.handleRevokeMessage,F=O.handleReplyMessage,L=O.handleCopyMessage,W=O.handleResendMessage,Y=O.handleForWardMessage,A={quote:e(e({isShow:!0},null==N?void 0:N.quote),null===(v=null==b?void 0:b.config)||void 0===v?void 0:v.quote),forward:e(e({isShow:!0},null==N?void 0:N.forward),null===(f=null==b?void 0:b.config)||void 0===f?void 0:f.forward),copy:e(e({isShow:!0,relateMessageType:[n.TYPES.MSG_TEXT]},null==N?void 0:N.copy),null===(S=null==b?void 0:b.config)||void 0===S?void 0:S.copy),delete:e(e({isShow:!0},null==N?void 0:N.delete),null===(w=null==b?void 0:b.config)||void 0===w?void 0:w.delete),revoke:e(e({isShow:!0},null==N?void 0:N.revoke),null===(M=null==b?void 0:b.config)||void 0===M?void 0:M.revoke),resend:e(e({isShow:!0},null==N?void 0:N.resend),null===(y=null==b?void 0:b.config)||void 0===y?void 0:y.resend)},Q=m({children:s("div",e({className:"message-plugin-item"},{children:[o("span",{children:"Recall"}),o(r,{width:20,height:20,type:a.REVOCATION})]})),handle:function(e){j.current.closeMore(),D(e)},message:x,isShow:A.revoke.isShow&&(null==x?void 0:x.status)===h.SUCCESS&&x.flow===g.OUT,relateMessageType:A.revoke.relateMessageType}),V=m({children:s("div",e({className:"message-plugin-item"},{children:[o("span",e({className:"del"},{children:"Delete"})),o(r,{width:20,height:20,type:a.DEL})]})),handle:function(e){j.current.closeMore(),P(e)},message:x,isShow:A.delete.isShow&&(null==x?void 0:x.status)===h.SUCCESS,relateMessageType:A.delete.relateMessageType}),B=m({children:s("div",e({className:"message-plugin-item"},{children:[o("span",{children:"Quote"}),o(r,{width:20,height:20,type:a.QUOTE})]})),handle:function(e){j.current.closeMore(),F(e)},message:x,isShow:A.quote.isShow&&(null==x?void 0:x.status)===h.SUCCESS,relateMessageType:A.quote.relateMessageType}),G=m({children:s("div",e({className:"message-plugin-item"},{children:[o("span",{children:"Copy"}),o(r,{width:20,height:20,type:a.COPY})]})),handle:function(e){j.current.closeMore(),L(e)},message:x,isShow:A.copy.isShow&&(null==x?void 0:x.status)===h.SUCCESS,relateMessageType:A.copy.relateMessageType}),H=m({children:s("div",e({className:"message-plugin-item"},{children:[o("span",{children:"Resend"}),o(r,{width:20,height:20,type:a.REPLY})]})),handle:function(e){j.current.closeMore(),W(e)},message:x,isShow:A.resend.isShow&&(null==x?void 0:x.status)!==h.SUCCESS,relateMessageType:A.resend.relateMessageType}),X=[Q,B,m({children:s("div",e({className:"message-plugin-item"},{children:[o("span",{children:"Forward"}),o(r,{width:20,height:20,type:a.FORWARD})]})),handle:function(e){j.current.closeMore(),Y(e)},message:x,isShow:A.forward.isShow&&(null==x?void 0:x.status)===h.SUCCESS,relateMessageType:A.forward.relateMessageType}),V,H,G],_=(C||(null==b?void 0:b.plugins)||X).filter((function(e){return e})),z=E||(null==b?void 0:b.MoreIcon)||o(r,{className:"icon-more",width:16,height:16,type:a.MORE}),J=T||(null==b?void 0:b.showNumber)||0;return(null==x?void 0:x.status)!==h.UNSEND&&o(t,{className:"message-plugin",customClass:R,ref:j,plugins:_,showNumber:J,MoreIcon:z,root:null==q?void 0:q.current,handleVisible:function(e){U("".concat(!e.top&&"message-plugin-top"," ").concat(!e.left&&"message-plugin-left"))}})}!function(e){e.quote="quote",e.forward="forward",e.copy="copy",e.delete="delete",e.resend="resend",e.revoke="revoke"}(p||(p={}));export{v as MessagePlugins};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as o}from"tslib";import{jsx as
|
|
1
|
+
import{__assign as o}from"tslib";import{jsx as t,jsxs as s}from"react/jsx-runtime";import e,{useState as r,useEffect as n}from"react";import i from"tim-js-sdk";import{MESSAGE_STATUS as l}from"../../constants.js";import{useTUIChatStateContext as m}from"../../context/TUIChatStateContext.js";import{useTUIMessageContext as a}from"../../context/TUIMessageContext.js";function u(e){var u=e.message,d=e.children,p=e.Progress,g=e.isShow,c=void 0!==g&&g,v=r(),f=v[0],S=v[1],h=r(0),x=h[0],P=h[1],M=m("MessageProgressWithContext").uploadPenddingMessageList,E=a("MessageProgressWithContext"),I=E.isShowProgress,j=void 0!==I&&I,C=E.Progress,T=p||C,y=c||j;return n((function(){M&&M.length>0&&M.map((function(o){return(null==o?void 0:o.ID)===(null==u?void 0:u.ID)&&(S(o),P(null==o?void 0:o.progress)),o}))}),[M]),y?T?t(T,{message:f}):!((null==u?void 0:u.type)!==i.TYPES.MSG_IMAGE&&(null==u?void 0:u.type)!==i.TYPES.MSG_VIDEO&&(null==u?void 0:u.type)!==i.TYPES.MSG_FILE||(null==u?void 0:u.status)!==l.UNSEND)&&s("div",o({className:"progress-box"},{children:[t("span",{className:"progress",style:{width:"".concat(100*x,"%")}}),d]})):null}var d=e.memo(u);function p(s){return t(d,o({},s))}export{p as MessageProgress};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as o,jsxs as t}from"react/jsx-runtime";import n,{useCallback as r}from"react";import s from"
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as o,jsxs as t}from"react/jsx-runtime";import n,{useCallback as r}from"react";import s from"tim-js-sdk";import{MESSAGE_OPERATE as i,MESSAGE_FLOW as l}from"../../constants.js";import{useTUIChatActionContext as a}from"../../context/TUIChatActionContext.js";import"../../context/TUIMessageContext.js";function m(n){var m=n.message,c=a().operateMessage,d=r((function(){var e;c(((e={})[i.REVOKE]=m,e))}),[c]);return t("div",e({className:"bubble message-system message-revoke"},{children:[(null==m?void 0:m.flow)===l.IN&&o("span",{children:(null==m?void 0:m.nick)||(null==m?void 0:m.from)}),(null==m?void 0:m.flow)!==l.IN&&o("span",{children:"you "}),o("span",{children:" recalled a message"}),(null==m?void 0:m.flow)===l.OUT&&(null==m?void 0:m.type)===s.TYPES.MSG_TEXT&&o("span",e({className:"edit",role:"button",tabIndex:0,onClick:d},{children:" Re-edit"}))]}))}var c=n.memo(m);function d(t){return o(c,e({},t))}export{d as MessageRevoke};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as
|
|
1
|
+
import{__assign as t}from"tslib";import{jsx as e,jsxs as r}from"react/jsx-runtime";import c from"react";import n from"tim-js-sdk";function s(c){var s=c.context,m=c.message,a=c.children;return e("div",t({className:"bubble message-text bubble-".concat(m.flow," ").concat((null==m?void 0:m.conversationType)===n.TYPES.CONV_GROUP?"group":"")},{children:r("div",t({className:"message-text-content"},{children:[s.text.map((function(r,c){var n=m.ID+c;return"text"===r.name?e("p",t({className:"message-text-content-p"},{children:r.text}),r.src+n):e("img",{className:"text-img",src:r.src,alt:""},r.src+n)})),a]}))}))}var m=c.memo(s);function a(r){return e(m,t({},r))}export{a as MessageText};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as o}from"react/jsx-runtime";import s from"react";import{useTUIChatStateContext as t}from"../../context/TUIChatStateContext.js";import{TUIMessageContextProvider as l}from"../../context/TUIMessageContext.js";import{useComponentContext as n}from"../../context/ComponentContext.js";import{useMessageHandler as m}from"./hooks/useMessageHandler.js";import"
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as o}from"react/jsx-runtime";import s from"react";import{useTUIChatStateContext as t}from"../../context/TUIChatStateContext.js";import{TUIMessageContextProvider as l}from"../../context/TUIMessageContext.js";import{useComponentContext as n}from"../../context/ComponentContext.js";import{useMessageHandler as m}from"./hooks/useMessageHandler.js";import"tim-js-sdk";import"../../constants.js";import"date-fns";import"../Icon/config.js";import"../Icon/type.js";import{TUIMessageDefault as i}from"./TUIMessageDefault.js";import{MessagePlugins as a}from"./MessagePlugins.js";import{MessageContext as r}from"./MessageContext.js";function u(s){var m=s.message,u=s.TUIMessage,d=s.MessagePlugins,g=s.MessageContext,v=s.handleDelete,c=s.CustemElement,f=s.TextElement,E=s.ImageElement,p=s.VideoElement,h=s.AudioElement,x=s.FileElement,M=s.MergerElement,w=s.LocationElement,C=s.FaceElement,j=s.className,T=s.filter,I=s.isShowTime,P=s.isShowRead,S=s.plugin,A=s.prefix,N=s.suffix,D=s.customName,F=s.showAvatar,U=s.showName,L=s.customAvatar,R=s.isShowProgress,V=s.Progress,k=n(),b=k.MessagePlugins,y=k.MessageContext,H=t("TUIMessage").messageConfig,q=u||i,z=d||b||a,B=g||y||r,G=T||(null==H?void 0:H.filter),J=m||(null==H?void 0:H.message);G&&G(J);var K={message:J,handleDelete:v||(null==H?void 0:H.handleDelete),CustemElement:c||(null==H?void 0:H.CustemElement),TextElement:f||(null==H?void 0:H.TextElement),ImageElement:E||(null==H?void 0:H.ImageElement),VideoElement:p||(null==H?void 0:H.VideoElement),AudioElement:h||(null==H?void 0:H.AudioElement),FileElement:x||(null==H?void 0:H.FileElement),MergerElement:M||(null==H?void 0:H.MergerElement),LocationElement:w||(null==H?void 0:H.LocationElement),FaceElement:C||(null==H?void 0:H.FaceElement),isShowTime:I||(null==H?void 0:H.isShowTime),isShowRead:P||(null==H?void 0:H.isShowRead),plugin:S||(null==H?void 0:H.plugin),prefix:A||(null==H?void 0:H.prefix),suffix:N||(null==H?void 0:H.suffix),customName:D||(null==H?void 0:H.customName),showAvatar:F||(null==H?void 0:H.showAvatar),showName:U||(null==H?void 0:H.showName),customAvatar:L||(null==H?void 0:H.customAvatar),isShowProgress:R||(null==H?void 0:H.isShowProgress),Progress:V||(null==H?void 0:H.Progress)};return o(l,e({value:K},{children:o(q,{message:J,MessageContext:B,MessagePlugins:z,className:j||(null==H?void 0:H.className)})}))}var d=s.memo(u);function g(s){var t=s.message,l=m({message:t}).handleDelMessage;return o(d,e({handleDelete:l},s))}export{g as TUIMessage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as s,jsxs as o}from"react/jsx-runtime";import t from"react";import
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as s,jsxs as o}from"react/jsx-runtime";import t from"react";import a from"tim-js-sdk";import{MessageBubble as m}from"./MessageBubble.js";import{MessageTip as i}from"./MessageTip.js";import{useTUIMessageContext as n,messageShowType as r}from"../../context/TUIMessageContext.js";import{useComponentContext as l}from"../../context/ComponentContext.js";import{MessageSystem as d}from"./MessageSystem.js";import{MessageRevoke as u}from"./MessageRevoke.js";import{MessageName as g}from"./MessageName.js";import{MessageAvatar as v}from"./MessageAvatar.js";function p(t){var p=t.message,c=t.MessageContext,f=t.MessagePlugins,M=t.className,P=l(),S=P.MessageContext,T=P.MessagePlugins,N=n("TUIMessage"),_=N.prefix,x=N.suffix,I=N.customName,j=N.showAvatar,C=void 0===j?r.IN:j,G=N.showName,R=void 0===G?r.IN:G,h=N.customAvatar,y=c||S,E=f||T;return o("div",e({className:"message-default\n ".concat((null==p?void 0:p.type)===a.TYPES.MSG_GRP_TIP||(null==p?void 0:p.isRevoked)?"tip":null==p?void 0:p.flow,"\n ").concat(M,"\n ")},{children:[(null==p?void 0:p.type)===a.TYPES.MSG_GRP_TIP&&s(i,{message:p}),(null==p?void 0:p.type)===a.TYPES.MSG_GRP_SYS_NOTICE&&s(d,{message:p}),(null==p?void 0:p.isRevoked)&&s(u,{message:p}),(null==p?void 0:p.type)!==a.TYPES.MSG_GRP_TIP&&(null==p?void 0:p.type)!==a.TYPES.MSG_GRP_SYS_NOTICE&&!(null==p?void 0:p.isRevoked)&&o("div",e({className:"".concat(null==p?void 0:p.flow),"data-message-id":null==p?void 0:p.ID},{children:[_,s(v,{message:p,CustomAvatar:h,showType:C}),o("main",e({className:"content"},{children:[s(g,{message:p,CustomName:I,showType:R}),s(m,e({message:p,Context:y,Plugins:E},{children:s(y,{message:p})}))]})),x]}),null==p?void 0:p.ID)]}))}var c=t.memo(p);function f(o){return o.message,s(c,e({},o))}export{f as TUIMessageDefault};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"
|
|
1
|
+
import e from"tim-js-sdk";import{translateGroupSystemNotice as a,handleTipMessageShowContext as S,handleLocationMessageShowContext as s,handleMergerMessageShowContext as r,handleCustomMessageShowContext as E,handleFileMessageShowContext as T,handleVideoMessageShowContext as G,handleAudioMessageShowContext as c,handleImageMessageShowContext as M,handleFaceMessageShowContext as P,handleTextMessageShowContext as _}from"../utils/index.js";var Y=function(Y){var k,t=Y.message;if(t)switch(null==t?void 0:t.type){case e.TYPES.MSG_TEXT:k=_(t);break;case e.TYPES.MSG_FACE:k=P(t);break;case e.TYPES.MSG_IMAGE:k=M(t);break;case e.TYPES.MSG_AUDIO:k=c(t);break;case e.TYPES.MSG_VIDEO:k=G(t);break;case e.TYPES.MSG_FILE:k=T(t);break;case e.TYPES.MSG_CUSTOM:k=E(t);break;case e.TYPES.MSG_MERGER:k=r(t);break;case e.TYPES.MSG_LOCATION:k=s(t);break;case e.TYPES.MSG_GRP_TIP:k=S(t);break;case e.TYPES.MSG_GRP_SYS_NOTICE:k=a(t)}return{context:k,message:t}};export{Y as useMessageContextHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as e,useLayoutEffect as t}from"react";import s from"
|
|
1
|
+
import{useState as e,useLayoutEffect as t}from"react";import s from"tim-js-sdk";import{useTUIKitContext as o}from"../../../context/TUIKitContext.js";import{useTUIChatStateContext as a}from"../../../context/TUIChatStateContext.js";import"tslib";import"react/jsx-runtime";import"../../../context/TUIMessageContext.js";import{JSONStringToParse as r}from"../../untils.js";var i,m=((i={})[s.TYPES.MSG_TEXT]=1,i[s.TYPES.MSG_FACE]=8,i[s.TYPES.MSG_IMAGE]=3,i[s.TYPES.MSG_AUDIO]=4,i[s.TYPES.MSG_VIDEO]=5,i[s.TYPES.MSG_FILE]=6,i[s.TYPES.MSG_CUSTOM]=2,i),n=function(i){var n=i.message,l=e(null),u=l[0],S=l[1],T=e(""),p=T[0],g=T[1],d=e(null),E=d[0],M=d[1],f=e(""),v=f[0],I=f[1],c=o("TUIChat").tim,x=a("useMessageReply").messageList;t((function(){C(n)}),[n]);var C=function(e){if(null==e?void 0:e.cloudCustomData){var t=r(null==n?void 0:n.cloudCustomData),o=(null==t?void 0:t.messageReply)||"";if(o){S(o),g(null==o?void 0:o.messageSender),I(null==o?void 0:o.messageID);var a=x.filter((function(e){var t=e.ID===(null==o?void 0:o.messageID),a=t&&m[e.type]===o.messageType,r=e.type!==s.TYPES.MSG_TEXT||e.payload.text===o.messageAbstract;return t&&a&&r}));M(a[0]||c.findMessage(null==o?void 0:o.messageID))}}};return{messageReply:u,sender:p,replyMessage:E,messageID:v,message:n}};export{n as useMessageReply};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as a}from"tslib";import t from"
|
|
1
|
+
import{__assign as a}from"tslib";import t from"tim-js-sdk";import{decodeText as e}from"./decodeText.js";import{MESSAGE_STATUS as c}from"../../../constants.js";import{JSONStringToParse as o}from"../../untils.js";function n(a){var t=a.split(".");return t[t.length-1]}function s(a){var e,c,o,s,r,i={message:a,text:""},p=a.nick||(null===(e=null==a?void 0:a.payload)||void 0===e?void 0:e.userIDList.join(","));switch((null===(o=null===(c=null==a?void 0:a.payload)||void 0===c?void 0:c.memberList)||void 0===o?void 0:o.length)>0&&(p="",null===(r=null===(s=null==a?void 0:a.payload)||void 0===s?void 0:s.memberList)||void 0===r||r.map((function(a){return p+="".concat((null==a?void 0:a.nick)||(null==a?void 0:a.userID),","),a})),p=p.slice(0,-1)),a.payload.operationType){case t.TYPES.GRP_TIP_MBR_JOIN:i.text="".concat(p," ").concat(n("message.tip.Join in group"));break;case t.TYPES.GRP_TIP_MBR_QUIT:i.text="".concat(n("message.tip.member"),":").concat(p," ").concat(n("message.tip.quit group"));break;case t.TYPES.GRP_TIP_MBR_KICKED_OUT:i.text="".concat(n("message.tip.member"),":").concat(p," ").concat(n("message.tip.by")).concat(a.payload.operatorID).concat(n("message.tip.kicked out of group"));break;case t.TYPES.GRP_TIP_MBR_SET_ADMIN:i.text="".concat(n("message.tip.member"),":").concat(p," ").concat(n("message.tip.become admin"));break;case t.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:i.text="".concat(n("message.tip.member"),":").concat(p," ").concat(n("message.tip.by revoked administrator"));break;case t.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:i.text=function(a){var t=a.payload,e=t.newGroupProfile,c=t.operatorID,o="",s=Object.keys(e)[0];switch(s){case"muteAllMembers":o=e[s]?"".concat(n("message.tip.admin")," ").concat(c," ").concat(n("message.tip.enable all staff mute")):"".concat(n("message.tip.admin")," ").concat(c," ").concat(n("message.tip.unmute everyone"));break;case"ownerID":o="".concat(e[s]," ").concat(n("message.tip.become the new owner"));break;case"groupName":o="".concat(c," ").concat(n("message.tip.modify group name")," ").concat(e[s]);break;case"notification":o="".concat(c," ").concat(n("message.tip.post a new announcement"))}return o}(a);break;case t.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:a.payload.memberList.map((function(a){return a.muteTime>0?i.text="".concat(n("message.tip.member"),":").concat(a.userID).concat(n("message.tip.muted")):i.text="".concat(n("message.tip.member"),":").concat(a.userID).concat(n("message.tip.unmuted")),a}));break;default:i.text="[".concat(n("message.tip.reminder message"),"]")}return i}function r(a){return{text:e(a.payload)}}function i(a){var t={message:a,name:"",url:""};return t.name=a.payload.data,a.payload.data.indexOf("@2x")<0&&(t.name="".concat(t.name,"@2x")),t.url="https://web.sdk.qcloud.com/im/assets/face-elem/".concat(t.name,".png"),t}function p(a){var t={lon:"",lat:"",href:"",url:"",description:"",message:a};return t.lon=a.payload.longitude.toFixed(6),t.lat=a.payload.latitude.toFixed(6),t.href="https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&"+"pointx=".concat(t.lon,"&pointy=").concat(t.lat,"&name=").concat(a.payload.description),t.url="https://apis.map.qq.com/ws/staticmap/v2/?"+"center=".concat(t.lat,",").concat(t.lon,"&zoom=10&size=300*150&maptype=roadmap&")+"markers=size:large|color:0xFFCCFF|label:k|".concat(t.lat,",").concat(t.lon,"&")+"key=UBNBZ-PTP3P-TE7DB-LHRTI-Y4YLE-VWBBD",t.description=a.payload.description,t}function m(a){return{progress:(null==a?void 0:a.status)===c.UNSEND&&a.progress,url:a.payload.imageInfoArray[1].url,message:a}}function l(a){var t,e;return{progress:(null==a?void 0:a.status)===c.UNSEND&&(null==a?void 0:a.progress),url:null===(t=null==a?void 0:a.payload)||void 0===t?void 0:t.videoUrl,snapshotUrl:null===(e=null==a?void 0:a.payload)||void 0===e?void 0:e.snapshotUrl,message:a}}function u(a){return{progress:(null==a?void 0:a.status)===c.UNSEND&&a.progress,url:a.payload.url,message:a,second:a.payload.second}}function d(a){var t="";return t=a.payload.fileSize>=1048576?"".concat((a.payload.fileSize/1048576).toFixed(2)," Mb"):a.payload.fileSize>=1024?"".concat((a.payload.fileSize/1024).toFixed(2)," Kb"):"".concat(a.payload.fileSize.toFixed(2),"B"),{progress:(null==a?void 0:a.status)===c.UNSEND&&a.progress,url:a.payload.fileUrl,message:a,name:a.payload.fileName,size:t}}function g(t){return a({message:t},t.payload)}function y(a){var t={},e={};try{t=o(a.payload.data)}catch(a){t={}}if(1!==t.businessID)return"";try{e=o(t.data)}catch(a){e={}}switch(t.actionType){case 1:return e.call_end>=0&&!t.groupID?"".concat(n("message.custom.talkTime"),":").concat(v(e.call_end)):t.groupID?"".concat(n("message.custom.groupCallEnd")):e.data&&"switchToAudio"===e.data.cmd?"".concat(n("message.custom.switchToAudioCall")):e.data&&"switchToVideo"===e.data.cmd?"".concat(n("message.custom.switchToVideoCall")):"".concat(n("message.custom.all"));case 2:return"".concat(n("message.custom.cancel"));case 3:return e.data&&"switchToAudio"===e.data.cmd?"".concat(n("message.custom.switchToAudioCall")):e.data&&"switchToVideo"===e.data.cmd?"".concat(n("message.custom.switchToVideoCall")):"".concat(n("message.custom.accepted"));case 4:return"".concat(n("message.custom.rejected"));case 5:return e.data&&"switchToAudio"===e.data.cmd?"".concat(n("message.custom.switchToAudioCall")):e.data&&"switchToVideo"===e.data.cmd?"".concat(n("message.custom.switchToVideoCall")):"".concat(n("message.custom.noResp"));default:return""}}function f(a){return{message:a,custom:y(a)||(null==a?void 0:a.payload)||"[".concat(n("message.custom.custom"),"]")}}function I(a){var t=a.payload.groupProfile.name||a.payload.groupProfile.groupID;switch(a.payload.operationType){case 1:return"".concat(a.payload.operatorID," ").concat(n("message.tip.申请加入群组"),":").concat(t);case 2:return"".concat(n("message.tip.成功加入群组"),":").concat(t);case 3:return"".concat(n("message.tip.申请加入群组"),":").concat(t," ").concat(n("message.tip.被拒绝"));case 4:return"".concat(n("message.tip.你被管理员")).concat(a.payload.operatorID," ").concat(n("message.tip.踢出群组"),":").concat(t);case 5:return"".concat(n("message.tip.群"),":").concat(t," ").concat(n("message.tip.被")," ").concat(a.payload.operatorID," ").concat(n("message.tip.解散"));case 6:return"".concat(a.payload.operatorID," ").concat(n("message.tip.创建群"),":").concat(t);case 7:case 12:return"".concat(a.payload.operatorID," ").concat(n("message.tip.邀请你加群"),":").concat(t);case 8:return"".concat(n("message.tip.你退出群组"),":").concat(t);case 9:return"".concat(n("message.tip.你被")).concat(a.payload.operatorID," ").concat(n("message.tip.设置为群"),":").concat(t," ").concat(n("message.tip.的管理员"));case 10:return"".concat(n("message.tip.你被")).concat(a.payload.operatorID," ").concat(n("message.tip.撤销群"),":").concat(t," ").concat(n("message.tip.的管理员身份"));case 13:return"".concat(a.payload.operatorID," ").concat(n("message.tip.同意加群"),":").concat(t);case 14:return"".concat(a.payload.operatorID," ").concat(n("message.tip.拒接加群"),":").concat(t);case 255:return"".concat(n("message.tip.自定义群系统通知"),": ").concat(a.payload.userDefinedField);default:return""}}function v(a){var t,e,c,o,n=a;return n>=3600?(e=parseInt("".concat(n/3600),10)<10?"0".concat(parseInt("".concat(n/3600),10)):parseInt("".concat(n/3600),10),c=parseInt("".concat(n%60/60),10)<10?"0".concat(parseInt("".concat(n%60/60),10)):parseInt("".concat(n%60/60),10),(o=n%3600<10?"0".concat(n%3600):n%3600)>60&&(c=parseInt("".concat(o/60),10)<10?"0".concat(parseInt("".concat(o/60),10)):parseInt("".concat(o/60),10),o=o%60<10?"0".concat(o%60):o%60),t="".concat(e,":").concat(c,":").concat(o)):n>=60&&n<3600?(c=parseInt("".concat(n/60),10)<10?"0".concat(parseInt("".concat(n/60),10)):parseInt("".concat(n/60),10),o=n%60<10?"0".concat(n%60):n%60,t="00:".concat(c,":").concat(o)):n<60&&(o=n<10?"0".concat(n):n,t="00:00:".concat(o)),t}export{y as extractCallingInfoFromMessage,v as formatTime,u as handleAudioMessageShowContext,f as handleCustomMessageShowContext,i as handleFaceMessageShowContext,d as handleFileMessageShowContext,m as handleImageMessageShowContext,p as handleLocationMessageShowContext,g as handleMergerMessageShowContext,r as handleTextMessageShowContext,s as handleTipMessageShowContext,l as handleVideoMessageShowContext,I as translateGroupSystemNotice};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as t}from"tslib";import{jsxs as o,jsx as e}from"react/jsx-runtime";import{useCallback as
|
|
1
|
+
import{__assign as t}from"tslib";import{jsxs as o,jsx as e}from"react/jsx-runtime";import{useCallback as s}from"react";import{useTUIChatActionContext as n}from"../../context/TUIChatActionContext.js";import"../../context/TUIMessageContext.js";import{Icon as i}from"../Icon/Icon.js";import{IconTypes as r}from"../Icon/type.js";import{MESSAGE_OPERATE as m}from"../../constants.js";import{useHandleQuoteMessage as a}from"./hooks/useHandleQuoteMessage.js";import{formatEmojiString as l}from"../TUIMessage/utils/emojiMap.js";function c(c){var p=c.message,u=n().operateMessage,d=a(p),f=d.cloudCustomData,h=d.message,g=s((function(){var t;u(((t={})[m.QUOTE]=null,t))}),[u]),j=null==f?void 0:f.messageReply;return j&&o("div",t({className:"input-quote"},{children:[o("div",t({className:"input-quote-content"},{children:[e("label",t({htmlFor:"input-quote-content"},{children:(null==h?void 0:h.nick)||(null==h?void 0:h.from)})),e("span",{children:l(null==j?void 0:j.messageAbstract,1)})]})),e(i,{className:"icon",width:12,height:12,type:r.CLOSE,onClick:g})]}))}export{c as InputQuoteDefalut};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as t}from"tslib";import{jsx as e,jsxs as s}from"react/jsx-runtime";import o from"react";import n from"
|
|
1
|
+
import{__assign as t}from"tslib";import{jsx as e,jsxs as s}from"react/jsx-runtime";import o from"react";import n from"tim-js-sdk";import{TUIMessageInputContextProvider as r}from"../../context/TUIMessageInputContext.js";import{useCreateMessageInputContext as i}from"./hooks/useCreateMessageInputContext.js";import{useMessageInputState as a}from"./hooks/useMessageInputState.js";import"../../constants.js";import{useTUIChatStateContext as u}from"../../context/TUIChatStateContext.js";import"../../context/TUIMessageContext.js";import{useComponentContext as m}from"../../context/ComponentContext.js";import"./hooks/useHandleQuoteMessage.js";import{EmptyStateIndicator as p}from"../EmptyStateIndicator/EmptyStateIndicator.js";import{InputQuoteDefalut as l}from"./InputQuoteDefalut.js";import{TUIMessageInputDefault as f}from"./TUIMessageInputDefault.js";import{InputPluginsDefalut as I}from"./InputPluginsDefalut.js";import{TUIForward as c}from"./TUIForward.js";import{Transmitter as d}from"./Transmitter.js";function g(s){var o=s.children,m=s.disabled,p=s.focus,l=s.pluginConfig,f=s.textareaRef,I=a(s),c=u("TUIMessageInput"),d=c.textareaRef,g=c.conversation,T=(null==g?void 0:g.type)===n.TYPES.CONV_SYSTEM,j=u("TUIMessageInput").TUIMessageInputConfig,x=p||(null==j?void 0:j.focus),v=i(t(t(t({},I),s),{textareaRef:f||(null==j?void 0:j.textareaRef)||d,disabled:m||(null==j?void 0:j.disabled)||T,focus:"boolean"!=typeof x||x,pluginConfig:l}));return e(r,t({value:v},{children:o}))}function T(o){var n=o.TUIMessageInput,r=o.InputPlugins,i=o.InputQuote,a=o.isTransmitter,T=o.className,j=u("TUIMessageInput").TUIMessageInputConfig,x=T||(null==j?void 0:j.className),v=a||(null==j?void 0:j.isTransmitter)||!1,M=m(),C=M.TUIMessageInput,U=M.InputPlugins,h=M.InputQuote,S=n||C||f,b=r||U||I||p,N=i||h||l;return e("div",t({className:"tui-message-input ".concat(x)},{children:s(g,t({},o,{children:[e(c,{}),e(N,{}),s("div",t({className:"tui-message-input-main"},{children:[s("div",t({className:"tui-message-input-box"},{children:[e(b,{}),e(S,{})]})),v&&e(d,{})]}))]}))}))}var j=o.memo(T);export{j as TUIMessageInput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e}from"tslib";import{useState as o,useEffect as n}from"react";import r from"
|
|
1
|
+
import{__awaiter as t,__generator as e}from"tslib";import{useState as o,useEffect as n}from"react";import r from"tim-js-sdk";import{MESSAGE_OPERATE as s}from"../../../constants.js";import{useTUIKitContext as i}from"../../../context/TUIKitContext.js";import{useTUIChatStateContext as a}from"../../../context/TUIChatStateContext.js";import{useTUIChatActionContext as c}from"../../../context/TUIChatActionContext.js";import"../../../context/TUIMessageContext.js";import"react/jsx-runtime";function m(m){var u=this,f=a("TUIMessageInputDefault").operateData,p=o([]),v=p[0],d=p[1],x=c(),l=x.sendMessage,C=x.createForwardMessage,g=i("TUIChat").tim,T=m||f[s.FORWARD];return n((function(){t(u,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,g.getConversationList()];case 1:return t=e.sent(),d(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.conversationList.filter((function(t){return t.type!==r.TYPES.CONV_SYSTEM}))),[2]}}))}))}),[g]),{message:T,conversationList:v,sendForwardMessage:function(t){t.map((function(t){var e=C({conversation:t,message:T});return l(e),t}))}}}export{m as useHandleForwardMessage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as e,useEffect as t}from"react";import o from"
|
|
1
|
+
import{useState as e,useEffect as t}from"react";import o from"tim-js-sdk";import{MESSAGE_OPERATE as s}from"../../../constants.js";import"tslib";import"react/jsx-runtime";import{useTUIChatStateContext as a}from"../../../context/TUIChatStateContext.js";import"../../../context/TUIMessageContext.js";var S,n,i=((S={})[o.TYPES.MSG_TEXT]=1,S[o.TYPES.MSG_CUSTOM]=2,S[o.TYPES.MSG_IMAGE]=3,S[o.TYPES.MSG_AUDIO]=4,S[o.TYPES.MSG_VIDEO]=5,S[o.TYPES.MSG_FILE]=6,S[o.TYPES.MSG_FACE]=8,S),l=((n={})[o.TYPES.MSG_CUSTOM]="[custom]",n[o.TYPES.MSG_IMAGE]="[image]",n[o.TYPES.MSG_AUDIO]="[audio]",n[o.TYPES.MSG_VIDEO]="[video]",n[o.TYPES.MSG_FILE]="[file]",n[o.TYPES.MSG_FACE]="[face]",n);function r(S){var n=a("TUIMessageInputDefault").operateData,r=e({messageReply:null}),E=r[0],T=r[1],m=function(e){var t,s=i[null==e?void 0:e.type];return{messageAbstract:(null==e?void 0:e.type)===o.TYPES.MSG_TEXT?null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.text:l[null==e?void 0:e.type],messageSender:(null==e?void 0:e.nick)||(null==e?void 0:e.from),messageID:null==e?void 0:e.ID,messageType:s,version:1}};return t((function(){var e=S||n[s.QUOTE];T({messageReply:e?m(e):null})}),[n,S]),{cloudCustomData:E,handleQuoteMessage:m,message:S||n[s.QUOTE]}}export{r as useHandleQuoteMessage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as t,__generator as i}from"tslib";import{jsx as s,jsxs as o}from"react/jsx-runtime";import n,{useState as l,useEffect as r}from"react";import{useTUIChatStateContext as a}from"../../context/TUIChatStateContext.js";import{useTUIChatActionContext as m}from"../../context/TUIChatActionContext.js";import"../../context/TUIMessageContext.js";import{useComponentContext as c}from"../../context/ComponentContext.js";import d from"./hooks/useEnrichedMessageList.js";import h from"./hooks/useMessageListElement.js";import{InfiniteScroll as g}from"../InfiniteScrollPaginator/InfiniteScroll.js";import{EmptyStateIndicator as u}from"../EmptyStateIndicator/EmptyStateIndicator.js";function f(n){var f=this,v=n.messageList,p=n.highlightedMessageId,M=n.loadMore,I=n.intervalsTimer,T=l(null),L=T[0],x=T[1],j=l(!1),C=j[0],S=j[1],E=a("TUIMessageList"),U=E.messageList,b=E.highlightedMessageId,y=E.isCompleted,k=E.isSameLastMessageID,
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as i}from"tslib";import{jsx as s,jsxs as o}from"react/jsx-runtime";import n,{useState as l,useEffect as r}from"react";import{useTUIChatStateContext as a}from"../../context/TUIChatStateContext.js";import{useTUIChatActionContext as m}from"../../context/TUIChatActionContext.js";import"../../context/TUIMessageContext.js";import{useComponentContext as c}from"../../context/ComponentContext.js";import d from"./hooks/useEnrichedMessageList.js";import h from"./hooks/useMessageListElement.js";import{InfiniteScroll as g}from"../InfiniteScrollPaginator/InfiniteScroll.js";import{EmptyStateIndicator as u}from"../EmptyStateIndicator/EmptyStateIndicator.js";function f(n){var f=this,v=n.messageList,p=n.highlightedMessageId,M=n.loadMore,I=n.intervalsTimer,T=l(null),L=T[0],x=T[1],j=l(!1),C=j[0],S=j[1],E=a("TUIMessageList"),U=E.messageList,b=E.highlightedMessageId,y=E.isCompleted,k=E.isSameLastMessageID,N=E.messageListRef,w=E.noMore,H=E.TUIMessageListConfig,V=m(),q=V.loadMore,A=V.setHighlightedMessageId,D=c(),P=D.TUIMessage,R=D.EmptyStateIndicator,z=void 0===R?u:R,B=p||(null==H?void 0:H.highlightedMessageId)||b,F=60*(I||(null==H?void 0:H.intervalsTimer)||30),G=d({messageList:v||(null==H?void 0:H.messageList)||U}).messageList,J=M||(null==H?void 0:H.loadMore)||q,K=h({enrichedMessageList:G,TUIMessage:P,intervalsTimer:F});return r((function(){t(f,void 0,void 0,(function(){var e,t,s,o,n;return i(this,(function(i){switch(i.label){case 0:return e=null===(n=null==L?void 0:L.parentElement)||void 0===n?void 0:n.parentElement,!y&&(null==e?void 0:e.clientHeight)>=(null==L?void 0:L.clientHeight)?[4,J()]:[3,2];case 1:i.sent(),i.label=2;case 2:return!(null==L?void 0:L.children)||C&&k||(t=(null==L?void 0:L.children)||[],s=t[t.length-1],o=setTimeout((function(){null==s||s.scrollIntoView({block:"end"}),S(!0),clearTimeout(o)}),100)),[2]}}))}))}),[K,C]),r((function(){if(B){var e=null==L?void 0:L.querySelector("[data-message-id='".concat(B,"']"));if(!e)return;var t=e.children[1].children;t[t.length-1].classList.add("high-lighted"),null==e||e.scrollIntoView({block:"center"});var i=setTimeout((function(){t[t.length-1].classList.remove("high-lighted"),clearTimeout(i),A("")}),1e3)}}),[B]),o("div",e({className:"message-list ".concat(C?"":"hide"),ref:N},{children:[w,w&&s("p",e({className:"no-more"},{children:"No More"})),s(g,e({className:"message-list-infinite-scroll",hasMore:!0,loadMore:J,threshold:1},{children:s("ul",e({ref:x},{children:(null==K?void 0:K.length)>0?K:s(z,{listType:"message"})}))}))]}))}var v=n.memo(f);function p(t){return s(v,e({},t))}export{p as TUIMessageList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as t,jsxs as a}from"react/jsx-runtime";import i,{useState as n}from"react";import l from"react-date-picker";import r from"
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as t,jsxs as a}from"react/jsx-runtime";import i,{useState as n}from"react";import l from"react-date-picker";import r from"tim-js-sdk";import{useTUIKitContext as o}from"../../context/TUIKitContext.js";import"../../context/TUIMessageContext.js";import{Avatar as c}from"../Avatar/Avatar.js";import{DivWithEdit as u}from"../DivWithEdit/DivWithEdit.js";import{Icon as d}from"../Icon/Icon.js";import{IconTypes as s}from"../Icon/type.js";import{handleDisplayAvatar as m}from"../untils.js";var v,p=((v={})[r.TYPES.GENDER_UNKNOWN]="unknow",v[r.TYPES.GENDER_MALE]="male",v[r.TYPES.GENDER_FEMALE]="female",v),f=["https://im.sdk.qcloud.com/download/tuikit-resource/avatar/avatar_1.png","https://im.sdk.qcloud.com/download/tuikit-resource/avatar/avatar_2.png","https://im.sdk.qcloud.com/download/tuikit-resource/avatar/avatar_3.png","https://im.sdk.qcloud.com/download/tuikit-resource/avatar/avatar_4.png","https://im.sdk.qcloud.com/download/tuikit-resource/avatar/avatar_5.png","https://im.sdk.qcloud.com/download/tuikit-resource/avatar/avatar_6.png"],h=[{label:"Male",value:r.TYPES.GENDER_MALE},{label:"Female",value:r.TYPES.GENDER_FEMALE}];function g(i){var r,v,g=i.userInfo,N=i.className,E=i.update,k=o("TUIProfileDefault").setTUIProfileShow,b=n(""),D=b[0],y=b[1],w=[{name:"Signature",value:null==g?void 0:g.selfSignature,type:"text",children:null},{name:"Gender",value:null===(r=p[null==g?void 0:g.gender])||void 0===r?void 0:r.replace(p[null==g?void 0:g.gender][0],null===(v=p[null==g?void 0:g.gender][0])||void 0===v?void 0:v.toLocaleUpperCase()),type:"select",children:t("ul",e({className:"select-list"},{children:null==h?void 0:h.map((function(a,i){var n="".concat(a.value).concat(i);return t("li",e({className:"select-list-item",role:"menuitem",tabIndex:i,onClick:function(){S(a)}},{children:a.label}),n)}))}))},{name:"Birthday",value:null==g?void 0:g.birthday,type:"select",children:t(l,{className:"tui-profile-birthday",calendarClassName:"tui-profile-birthday-calendar",isOpen:!0,format:"y-MM-dd",onChange:function(e){j(e)},value:function(e){if(8===(null==e?void 0:e.length)){var t=Number(e.slice(0,4)),a=Number(e.slice(4,6)),i=Number(e.slice(-2));return new Date(t,a-1,i)}return new Date}("".concat(null==g?void 0:g.birthday))})}],I=function(e){y(e)},M=function(e){E(e),y("")},_=function(e){var t,a="";switch(null==e?void 0:e.name){case"nick":a="nick";break;case"Signature":a="selfSignature";break;default:return void y("")}var i=((t={})[a]=e.value,t);M(i)},S=function(e){M({gender:e.value})},j=function(e){var t,a,i,n;M({birthday:Number((t=e,a=t.getDate()>9?t.getDate():"0".concat(t.getDate()),i=t.getMonth()>8?t.getMonth()+1:"0".concat(t.getMonth()+1),n=t.getFullYear(),"".concat(n).concat(i).concat(a)))})};return a("div",e({className:"".concat(N," tui-profile")},{children:[a("header",e({className:"tui-profile-header"},{children:[t(d,{width:9,height:16,type:s.BACK,onClick:function(){k(!1)}}),t("h1",{children:"Personal information"})]})),a("main",e({className:"tui-profile-main"},{children:[t("div",e({className:"tui-profile-avatar"},{children:t(c,{image:m(null==g?void 0:g.avatar),size:94,update:function(e){M({avatar:e})},list:f})})),t(u,{name:"nick",className:"tui-profile-nick",value:null==g?void 0:g.nick,type:"text",toggle:I,isEdit:"nick"===D,confirm:_,close:function(){y("")}}),a("div",e({className:"tui-profile-ID"},{children:[t("h5",{children:"ID:"}),t("span",{children:null==g?void 0:g.userID})]}))]})),t("ul",e({className:"tui-profile-list"},{children:w.map((function(i){var n="".concat(i.name);return a("li",e({className:"tui-profile-list-item"},{children:[t("h4",{children:i.name}),t(u,e({className:"tui-profile-div-with-edit",classEditName:"tui-profile-edit",name:i.name,value:null==i?void 0:i.value,type:i.type,toggle:I,isEdit:D===i.name,confirm:_,close:function(){y("")}},{children:null==i?void 0:i.children}))]}),n)}))}))]}))}var N=i.memo(g);function E(a){var i=e({},a);return t(N,e({},i))}export{E as TUIProfileDefault};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as n,__assign as e}from"tslib";import{useState as r,useCallback as o,useEffect as i}from"react";import u from"
|
|
1
|
+
import{__awaiter as t,__generator as n,__assign as e}from"tslib";import{useState as r,useCallback as o,useEffect as i}from"react";import u from"tim-js-sdk";import{useTUIKitContext as a}from"../../../context/TUIKitContext.js";import"react/jsx-runtime";import"../../../context/TUIMessageContext.js";function c(){var c=this,l=r(null),s=l[0],f=l[1],d=a("useMyProfile"),m=d.tim,v=d.myProfile,p=o((function(){return t(c,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return v?(f(v),[3,3]):[3,1];case 1:return[4,null==m?void 0:m.getMyProfile()];case 2:t=n.sent(),f(null==t?void 0:t.data),n.label=3;case 3:return[2]}}))}))}),[m]),P=o((function(r){return t(c,void 0,void 0,(function(){var t,o;return n(this,(function(n){switch(n.label){case 0:return[4,null==m?void 0:m.updateMyProfile(r)];case 1:return t=n.sent(),o=e({},s),Object.keys(t.data).map((function(n){return o[n]=t.data[n],n})),f(o),[2,t]}}))}))}),[m]),E=function(t){console.log("onProfileUpdated",t.data)};return i((function(){return t(c,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,p()];case 1:return t.sent(),[2]}}))})),null==m||m.on(u.EVENT.PROFILE_UPDATED,E),function(){null==m||m.off(u.EVENT.PROFILE_UPDATED,E)}}),[m]),{myProfile:s,updateMyProfile:P}}export{c as useMyProfile};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isThisYear as
|
|
1
|
+
import{isThisYear as r,format as t,isToday as e,isYesterday as i,formatDistance as n,isThisWeek as o}from"date-fns";import a from"tim-js-sdk";import"tslib";import"react/jsx-runtime";import"react";import"./Icon/config.js";import"./Icon/type.js";import{defaultGroupAvatarWork as c,defaultUserAvatar as f}from"./Avatar/default.js";function p(r){if("string"==typeof r)try{return!!JSON.parse(r)}catch(r){return!1}return!1}function s(r){return p(r)?JSON.parse(r):r}var m=function(r,t){void 0===t&&(t=a.TYPES.CONV_C2C);var e=r;if(!r)switch(t){case a.TYPES.CONV_C2C:e=f;break;case a.TYPES.CONV_GROUP:default:e=c}return e},u=function(a){return a?r(a)?e(a)?t(a,"p"):i(a)?n(a,new Date):o(a)?t(a,"eeee"):t(a,"MMM dd"):t(a,"yyyy MMM dd"):""};export{s as JSONStringToParse,u as getTimeStamp,m as handleDisplayAvatar,p as isJSON};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as o}from"tslib";import{jsx as e}from"react/jsx-runtime";import
|
|
1
|
+
import{__assign as o}from"tslib";import{jsx as e}from"react/jsx-runtime";import t,{useContext as s}from"react";import{TUIConversationList as n}from"../components/TUIConversationList/TUIConversationList.js";import"tim-js-sdk";import"./TUIMessageContext.js";import"../components/TUIProfile/TUIProfileDefault.js";import"../constants.js";import"date-fns";import"../components/Icon/config.js";import"../components/Icon/type.js";import"../components/TUIMessage/hooks/useMessageReply.js";import"../components/TUIMessage/MessagePlugins.js";import"../components/TUIMessage/MessageContext.js";import"../components/TUIMessageInput/hooks/useHandleQuoteMessage.js";import"../components/Switch/Switch.js";var r=t.createContext(void 0);function i(t){var s=t.children,i=t.value;return e(r.Provider,o({value:i},{children:s||e(n,{})}))}var m=function(o){var e=s(r);return!e&&o?{}:e};export{r as TUIConversationContext,i as TUIConversationProvider,m as useTUIConversationContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as o}from"tslib";import e from"
|
|
1
|
+
import{__awaiter as t,__generator as o}from"tslib";import e from"tim-js-sdk";import{useTUIConversationContext as n}from"../context/TUIConversationContext.js";var r=function(r){var i=n("useConversation");return{createConversation:i.createConversation||function(n){return t(void 0,void 0,void 0,(function(){var t,i,a,s,u,c,p,v,m,d,C,f,l,g,b;return o(this,(function(o){switch(o.label){case 0:return"string"!=typeof n?[3,2]:[4,r.getConversationProfile(n)];case 1:return[2,o.sent().data.conversation];case 2:return t=n.name,i=n.type,a=n.groupID,s=n.introduction,u=n.notification,c=n.avatar,p=n.maxMemberNum,v=n.joinOption,m=n.memberList,d=void 0===m?[]:m,C=n.groupCustomField,f=void 0===C?[]:C,l=n.isSupportTopic,[4,r.createGroup({name:t,type:i,groupID:a,introduction:s,notification:u,avatar:c,maxMemberNum:p,joinOption:v,memberList:d,groupCustomField:f,isSupportTopic:l})];case 3:return g=o.sent(),b=g.data.group.groupID,i!==e.TYPES.GRP_AVCHATROOM?[3,5]:[4,r.joinGroup({groupID:b,type:e.TYPES.GRP_AVCHATROOM})];case 4:o.sent(),o.label=5;case 5:return[4,r.getConversationProfile("GROUP".concat(b))];case 6:return[2,o.sent().data.conversation]}}))}))},pinConversation:function(t){return r.pinConversation(t)},deleteConversation:i.deleteConversation||function(t){return r.deleteConversation(t)}}};export{r as useConversation};
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{TUIKit}from"./components/TUIKit/TUIKit.js";export{useTUIKit}from"./components/TUIKit/hooks/useTUIKit.js";export{useCreateTUIKitContext}from"./components/TUIKit/hooks/useCreateTUIKitContext.js";export{TUIConversation,UnMemoizedTUIConversation}from"./components/TUIConversation/TUIConversation.js";export{TUIConversationList,UnMemoTUIConversationList}from"./components/TUIConversationList/TUIConversationList.js";import"tslib";import"react";import"
|
|
1
|
+
export{TUIKit}from"./components/TUIKit/TUIKit.js";export{useTUIKit}from"./components/TUIKit/hooks/useTUIKit.js";export{useCreateTUIKitContext}from"./components/TUIKit/hooks/useCreateTUIKitContext.js";export{TUIConversation,UnMemoizedTUIConversation}from"./components/TUIConversation/TUIConversation.js";export{TUIConversationList,UnMemoTUIConversationList}from"./components/TUIConversationList/TUIConversationList.js";import"tslib";import"react";import"tim-js-sdk";export{TUIChat}from"./components/TUIChat/TUIChat.js";export{ConversationPreview}from"./components/ConversationPreview/ConversationPreview.js";export{ConversationPreviewContent,unMemoConversationPreviewContent}from"./components/ConversationPreview/ConversationPreviewContent.js";export{TUIChatHeader}from"./components/TUIChatHeader/TUIChatHeader.js";export{TUIChatHeaderDefault}from"./components/TUIChatHeader/TUIChatHeaderDefault.js";export{TUIMessageList}from"./components/TUIMessageList/TUIMessageList.js";export{TUIMessage}from"./components/TUIMessage/TUIMessage.js";export{MessagePlugins}from"./components/TUIMessage/MessagePlugins.js";export{MessageContext}from"./components/TUIMessage/MessageContext.js";export{TUIMessageInput}from"./components/TUIMessageInput/TUIMessageInput.js";export{TUIMessageInputDefault}from"./components/TUIMessageInput/TUIMessageInputDefault.js";export{InputPluginsDefalut}from"./components/TUIMessageInput/InputPluginsDefalut.js";export{TUIProfile}from"./components/TUIProfile/TUIProfile.js";export{TUIProfileDefault}from"./components/TUIProfile/TUIProfileDefault.js";export{Avatar}from"./components/Avatar/Avatar.js";export{defaultGroupAvatarAVChatRoom,defaultGroupAvatarMeeting,defaultGroupAvatarPublic,defaultGroupAvatarWork,defaultUserAvatar}from"./components/Avatar/default.js";export{ConversationSearchInput}from"./components/ConversationSearch/ConversationSearchInput.js";export{ConversationSearchResult}from"./components/ConversationSearch/ConversationSearchResult.js";export{TUIManage}from"./components/TUIManage/TUIManage.js";export{Popup}from"./components/Popup/index.js";export{Checkbox}from"./components/Checkbox/index.js";export{DivWithEdit}from"./components/DivWithEdit/DivWithEdit.js";export{Icon,changeTypeToIconClassName}from"./components/Icon/Icon.js";export{IconTypes}from"./components/Icon/type.js";export{EmptyStateIndicator}from"./components/EmptyStateIndicator/EmptyStateIndicator.js";export{Input}from"./components/Input/Input.js";export{Model}from"./components/Model/index.js";export{Plugins}from"./components/Plugins/index.js";export{Switch}from"./components/Switch/Switch.js";export{Toast}from"./components/Toast/index.js";export{TUIKitContext,TUIKitProvider,useTUIKitContext}from"./context/TUIKitContext.js";export{TUIChatStateContext,TUIChatStateContextProvider,useTUIChatStateContext}from"./context/TUIChatStateContext.js";export{TUIChatActionContext,TUIChatActionProvider,useTUIChatActionContext}from"./context/TUIChatActionContext.js";export{TUIMessageContext,TUIMessageContextProvider,messageShowType,useTUIMessageContext}from"./context/TUIMessageContext.js";export{ComponentContext,ComponentProvider,useComponentContext}from"./context/ComponentContext.js";export{TUIMessageInputContext,TUIMessageInputContextProvider,useTUIMessageInputContext}from"./context/TUIMessageInputContext.js";export{useConversation}from"./hooks/useConversation.js";export{useProfile}from"./hooks/useProfile.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tencentcloud/chat-uikit-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"date-fns": "^2.29.3",
|
|
68
68
|
"react": "^18.2.0",
|
|
69
69
|
"react-date-picker": "^9.0.0",
|
|
70
|
+
"tim-js-sdk": "^2.24.2",
|
|
70
71
|
"tim-upload-plugin": "^1.0.5",
|
|
71
72
|
"tslib": "^2.4.1"
|
|
72
73
|
}
|
package/readme.zh_cn.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
_[English](README.md) | 简体中文_
|
|
2
|
+
# [chat-uikit-react](https://www.tencentcloud.com/document/product/1047/34279/)
|
|
3
|
+
>Chat UIKit 是基于腾讯云 IM SDK 的一款 UI 组件库,它提供了一些通用的 UI 组件,包含会话、聊天、关系链、群组、音视频通话等功能。
|
|
4
|
+
基于 UI 组件您可以像搭积木一样快速搭建起自己的业务逻辑。
|
|
5
|
+
Chat UIKit 中的组件在实现 UI 功能的同时,会调用 IM SDK 相应的接口实现 IM 相关逻辑和数据的处理,因而开发者在使用 Chat UIKit 时只需关注自身业务或个性化扩展即可。
|
|
6
|
+
|
|
7
|
+
## Demos
|
|
8
|
+
我们已经构建了用于展示聊天功能的实例演示程序,您可以在我们的网站上预览这些
|
|
9
|
+
|
|
10
|
+
| | sample-chat | live-chat |
|
|
11
|
+
| ------ | ------ | ------ |
|
|
12
|
+
| |  |  |
|
|
13
|
+
| demo 在线体验地址 | [sample-chat](https://web.sdk.qcloud.com/im/demo/intl/index.html) | [live-chat](https://web.sdk.qcloud.com/im/demo/intl/index.html?scene=live) |
|
|
14
|
+
| 源码地址 | [sample-chat-code](https://github.com/TencentCloud/chat-uikit-react/tree/main/examples/sample-chat) | [live-chat-code](https://github.com/TencentCloud/chat-uikit-react/tree/main/examples/live-chat) |
|
|
15
|
+
|
|
16
|
+
您可以通过 [demos](https://web.sdk.qcloud.com/im/demo/intl/index.html) 体验效果, 并可以通过 [open source code](https://github.com/TencentCloud/chat-uikit-react) 获取源码
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Running Demo
|
|
20
|
+
|
|
21
|
+
### 步骤一:下载源码
|
|
22
|
+
```
|
|
23
|
+
# Run the code in CLI
|
|
24
|
+
$ git clone https://github.com/TencentCloud/chat-uikit-react
|
|
25
|
+
# Go to the project
|
|
26
|
+
$ cd chat-uikit-react
|
|
27
|
+
# Install dependencies of the demo
|
|
28
|
+
$ npm install && cd examples/sample-chat && npm install
|
|
29
|
+
```
|
|
30
|
+
### 步骤二:配置 demo
|
|
31
|
+
1. 打开`examples/sample-chat`项目,通过路径`./examples/sample-chat/src/debug/GenerateTestUserSig.js`找到`GenerateTestUserSig.js`文件。
|
|
32
|
+
2. 在`GenerateTestUserSig.js`文件中设置 `SDKAPPID` 和 `SECRETKEY` ,其值可以在[IM控制台](https://console.tencentcloud.com/im)中获取。 点击目标应用卡片,进入其配置页面。
|
|
33
|
+

|
|
34
|
+
3. 在 **Basic Information** 区域,点击 **Display key**,将密钥信息复制并保存到 GenerateTestUserSig 文件中。
|
|
35
|
+
>!
|
|
36
|
+
>- 本文提到的生成 UserSig 的方案是在客户端代码中配置 SECRETKEY,该方法中 SECRETKEY 很容易被反编译逆向破解,一旦您的密钥泄露,攻击者就可以盗用您的腾讯云流量,因此**该方法仅适合本地跑通 Demo 和功能调试。**
|
|
37
|
+
>- 正确的 UserSig 签发方式是将 UserSig 的计算代码集成到您的服务端,并提供面向 App 的接口,在需要 UserSig 时由您的 App 向业务服务器发起请求获取动态 UserSig。更多详情请参见 [服务端生成 UserSig](https://www.tencentcloud.com/document/product/1047/34385)。
|
|
38
|
+
|
|
39
|
+
### 步骤三:启动项目
|
|
40
|
+
```
|
|
41
|
+
# Launch the project
|
|
42
|
+
$ cd examples/sample-chat
|
|
43
|
+
$ npm run start
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 步骤四:发送您的第一条消息
|
|
47
|
+
1. 项目启动成功后,点击“+”图标,进行创建会话。
|
|
48
|
+
2. 在输入框中搜索另一个用户的 userID。
|
|
49
|
+
3. 点击用户头像发起会话。
|
|
50
|
+
4. 在输入框输入消息,按下"enter"键发送。
|
|
51
|
+

|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Quick links
|
|
55
|
+
- [Web demo](https://web.sdk.qcloud.com/im/demo/intl/index.html)
|
|
56
|
+
- [Client APIs](https://www.tencentcloud.com/document/product/1047/33999)
|
|
57
|
+
- [Free demo download](https://www.tencentcloud.com/document/product/1047/34279)
|
|
58
|
+
- [FAQs](https://www.tencentcloud.com/document/product/1047/34455)
|
|
59
|
+
- [Source code in GitHub](https://github.com/TencentCloud/chat-uikit-react)
|
|
60
|
+
- [Generating UserSig](https://www.tencentcloud.com/document/product/1047/34385)
|
|
@@ -65,7 +65,8 @@ export const getDisplayMessage = (conversation:Conversation, myProfile:Profile)
|
|
|
65
65
|
let from = '';
|
|
66
66
|
switch (type) {
|
|
67
67
|
case TIM.TYPES.CONV_GROUP:
|
|
68
|
-
from = lastMessage?.fromAccount === myProfile?.userID ? 'You
|
|
68
|
+
from = lastMessage?.fromAccount === myProfile?.userID ? 'You' : `${nameCard || nick || fromAccount || ''}`;
|
|
69
|
+
from = `${from ? `${from}:` : ''}`;
|
|
69
70
|
break;
|
|
70
71
|
case TIM.TYPES.CONV_C2C:
|
|
71
72
|
from = isRevoked ? 'you ' : '';
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren, useMemo } from 'react';
|
|
2
|
+
import { Conversation } from 'tim-js-sdk';
|
|
2
3
|
import { TUIConversationProvider, TUIConversationContextValue } from '../../context/TUIConversationContext';
|
|
3
4
|
import { TUIConversationList } from '../TUIConversationList';
|
|
4
5
|
import { TUIProfile } from '../TUIProfile';
|
|
@@ -6,6 +7,7 @@ import { TUIProfile } from '../TUIProfile';
|
|
|
6
7
|
interface TUIConversationProps {
|
|
7
8
|
createConversation?:(conversationID:string) => Promise<any>,
|
|
8
9
|
deleteConversation?:(conversationID:string) => Promise<any>,
|
|
10
|
+
filterConversation?:(conversationList: Array<Conversation>) => Array<Conversation>,
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export function UnMemoizedTUIConversation<T extends TUIConversationProps>(
|
|
@@ -15,15 +17,18 @@ export function UnMemoizedTUIConversation<T extends TUIConversationProps>(
|
|
|
15
17
|
children,
|
|
16
18
|
createConversation,
|
|
17
19
|
deleteConversation,
|
|
20
|
+
filterConversation,
|
|
18
21
|
} = props;
|
|
19
22
|
const TUIConversationValue: TUIConversationContextValue = useMemo(
|
|
20
23
|
() => ({
|
|
21
24
|
createConversation,
|
|
22
25
|
deleteConversation,
|
|
26
|
+
filterConversation,
|
|
23
27
|
}),
|
|
24
28
|
[
|
|
25
29
|
createConversation,
|
|
26
30
|
deleteConversation,
|
|
31
|
+
filterConversation,
|
|
27
32
|
],
|
|
28
33
|
);
|
|
29
34
|
|
|
@@ -14,6 +14,7 @@ import { ConversationCreate } from '../ConversationCreate';
|
|
|
14
14
|
import { Icon, IconTypes } from '../Icon';
|
|
15
15
|
import { getDisplayTitle } from '../ConversationPreview/utils';
|
|
16
16
|
import { useConversationUpdate } from './hooks/useConversationUpdate';
|
|
17
|
+
import { useTUIConversationContext } from '../../context/TUIConversationContext';
|
|
17
18
|
|
|
18
19
|
interface Props {
|
|
19
20
|
filters?: object,
|
|
@@ -25,16 +26,22 @@ interface Props {
|
|
|
25
26
|
setConversationList: React.Dispatch<React.SetStateAction<Array<Conversation>>>,
|
|
26
27
|
event: () => void
|
|
27
28
|
) => void,
|
|
29
|
+
filterConversation?:(conversationList: Array<Conversation>) => Array<Conversation>,
|
|
28
30
|
}
|
|
29
31
|
export function UnMemoTUIConversationList<T extends Props>(props: T):React.ReactElement {
|
|
30
32
|
const {
|
|
31
33
|
Preview,
|
|
32
34
|
Container = ConversationListContainer,
|
|
33
35
|
onConversationListUpdated,
|
|
36
|
+
filterConversation: propsFilterConversation,
|
|
34
37
|
} = props;
|
|
35
38
|
const {
|
|
36
39
|
tim, customClasses, conversation, setActiveConversation, setTUIProfileShow,
|
|
37
40
|
} = useTUIKitContext('TUIConversationList');
|
|
41
|
+
const {
|
|
42
|
+
filterConversation: contextFilterConversation,
|
|
43
|
+
} = useTUIConversationContext('TUIConversationList');
|
|
44
|
+
const filterConversation = propsFilterConversation || contextFilterConversation;
|
|
38
45
|
const [conversationUpdateCount, setConversationUpdateCount] = useState(0);
|
|
39
46
|
const forceUpdate = () => setConversationUpdateCount((count) => count + 1);
|
|
40
47
|
|
|
@@ -50,8 +57,13 @@ export function UnMemoTUIConversationList<T extends Props>(props: T):React.React
|
|
|
50
57
|
const {
|
|
51
58
|
conversationList,
|
|
52
59
|
setConversationList,
|
|
53
|
-
} = useConversationList(tim, activeConversationHandler);
|
|
54
|
-
useConversationUpdate(
|
|
60
|
+
} = useConversationList(tim, activeConversationHandler, filterConversation);
|
|
61
|
+
useConversationUpdate(
|
|
62
|
+
setConversationList,
|
|
63
|
+
onConversationListUpdated,
|
|
64
|
+
forceUpdate,
|
|
65
|
+
filterConversation,
|
|
66
|
+
);
|
|
55
67
|
const [searchValue, setSearchValue] = useState('');
|
|
56
68
|
const [searchResult, setSearchResult] = useState(conversationList);
|
|
57
69
|
const [conversationCreated, setConversationCreated] = useState(false);
|
|
@@ -7,6 +7,7 @@ function useConversationList(
|
|
|
7
7
|
conversationList: Array<Conversation>,
|
|
8
8
|
setConversationList: React.Dispatch<React.SetStateAction<Array<Conversation>>>,
|
|
9
9
|
) => void,
|
|
10
|
+
filterConversation?:(conversationList: Array<Conversation>) => Array<Conversation>,
|
|
10
11
|
) {
|
|
11
12
|
const [conversationList, setConversationList] = useState<Array<Conversation>>([]);
|
|
12
13
|
const queryConversation = async (queryType?: string) => {
|
|
@@ -17,9 +18,14 @@ function useConversationList(
|
|
|
17
18
|
|
|
18
19
|
const res = await tim?.getConversationList();
|
|
19
20
|
if (res?.code === 0) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
let resConversationList = [];
|
|
22
|
+
if (filterConversation) {
|
|
23
|
+
resConversationList = filterConversation(res.data.conversationList);
|
|
24
|
+
} else {
|
|
25
|
+
resConversationList = res.data.conversationList.filter(
|
|
26
|
+
(item) => item.type !== TIM.TYPES.CONV_SYSTEM,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
23
29
|
const newConversationList = queryType === 'reload'
|
|
24
30
|
? resConversationList
|
|
25
31
|
: [...conversationList, resConversationList];
|
|
@@ -9,14 +9,19 @@ export const useConversationUpdate = (
|
|
|
9
9
|
event: any
|
|
10
10
|
) => void,
|
|
11
11
|
forceUpdate?: () => void,
|
|
12
|
+
filterConversation?:(conversationList: Array<Conversation>) => Array<Conversation>,
|
|
12
13
|
) => {
|
|
13
14
|
const { tim } = useTUIKitContext('useConversationUpdate');
|
|
14
15
|
useEffect(() => {
|
|
15
16
|
const onConversationListUpdated = (event:any) => {
|
|
16
17
|
if (setConversationList) {
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
18
|
+
if (filterConversation) {
|
|
19
|
+
setConversationList(filterConversation(event.data));
|
|
20
|
+
} else {
|
|
21
|
+
setConversationList(event.data.filter(
|
|
22
|
+
(item) => item.type !== TIM.TYPES.CONV_SYSTEM,
|
|
23
|
+
));
|
|
24
|
+
}
|
|
20
25
|
}
|
|
21
26
|
if (forceUpdate) {
|
|
22
27
|
forceUpdate();
|
|
@@ -74,6 +74,9 @@ export function handleShowLastMessage(item: Conversation) {
|
|
|
74
74
|
&& conversation.messageRemindType === TIM.TYPES.MSG_REMIND_ACPT_NOT_NOTE
|
|
75
75
|
? t(`[${conversation.unreadCount > 99 ? '99+' : conversation.unreadCount}条]`)
|
|
76
76
|
: '';
|
|
77
|
+
if (!lastMessage.lastTime) {
|
|
78
|
+
return '';
|
|
79
|
+
}
|
|
77
80
|
// Determine the lastmessage sender of the group.
|
|
78
81
|
// Namecard / Nick / userid is displayed by priority
|
|
79
82
|
if (conversation.type === TIM.TYPES.CONV_GROUP) {
|