whyuzeim 1.0.19 → 1.0.21
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.
|
@@ -14,6 +14,7 @@ var _slicedToArray = require('@babel/runtime-corejs3/helpers/esm/slicedToArray')
|
|
|
14
14
|
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
15
15
|
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
16
16
|
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
17
|
+
var _setInterval = require('@babel/runtime-corejs3/core-js-stable/set-interval');
|
|
17
18
|
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
18
19
|
var React = require('react');
|
|
19
20
|
var agoraChatUikit = require('agora-chat-uikit');
|
|
@@ -32,29 +33,33 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
32
33
|
var _useContext = React.useContext(context.Context);
|
|
33
34
|
_useContext.http;
|
|
34
35
|
var userInfo = _useContext.userInfo;
|
|
35
|
-
var _useState = React.useState(
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
var _useState = React.useState(true),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
loading = _useState2[0],
|
|
39
|
+
setLoading = _useState2[1]; // 新增状态用于控制加载
|
|
40
|
+
var _useState3 = React.useState({
|
|
41
|
+
headerImageURL: "",
|
|
42
|
+
conversationName: "",
|
|
38
43
|
memberCount: 0,
|
|
39
|
-
chatType:
|
|
40
|
-
conversationId:
|
|
44
|
+
chatType: "singleChat",
|
|
45
|
+
conversationId: ""
|
|
41
46
|
}),
|
|
42
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
-
headerInfo = _useState2[0],
|
|
44
|
-
setHeaderInfo = _useState2[1];
|
|
45
|
-
var _useState3 = React.useState(undefined),
|
|
46
47
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
headerInfo = _useState4[0],
|
|
49
|
+
setHeaderInfo = _useState4[1];
|
|
50
|
+
var _useState5 = React.useState(undefined),
|
|
51
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
52
|
+
currentConversation = _useState6[0],
|
|
53
|
+
setCurrentConversation = _useState6[1];
|
|
49
54
|
var renderTxtMsg = function renderTxtMsg(msg) {
|
|
50
55
|
var _userInfo$uid;
|
|
51
56
|
var isMySelf = (msg === null || msg === void 0 ? void 0 : msg.bySelf) === true || (msg === null || msg === void 0 ? void 0 : msg.from.toLowerCase()) === ((_userInfo$uid = userInfo.uid) === null || _userInfo$uid === void 0 ? void 0 : _userInfo$uid.toLowerCase());
|
|
52
57
|
return /*#__PURE__*/React.createElement(agoraChatUikit.BaseMessage, {
|
|
53
|
-
bubbleType:
|
|
58
|
+
bubbleType: "none",
|
|
54
59
|
reaction: false,
|
|
55
60
|
select: false,
|
|
56
61
|
thread: false,
|
|
57
|
-
direction: isMySelf ?
|
|
62
|
+
direction: isMySelf ? "rtl" : "ltr",
|
|
58
63
|
renderUserProfile: function renderUserProfile() {
|
|
59
64
|
return null;
|
|
60
65
|
},
|
|
@@ -72,32 +77,32 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
72
77
|
var _userInfo$uid2;
|
|
73
78
|
// 格式化消息时间
|
|
74
79
|
var formatMessageTime = function formatMessageTime(timestamp) {
|
|
75
|
-
if (!timestamp) return
|
|
80
|
+
if (!timestamp) return "";
|
|
76
81
|
var date = new Date(timestamp);
|
|
77
82
|
var now = new Date();
|
|
78
83
|
// 判断是否是同一天
|
|
79
84
|
var isToday = date.toDateString() === now.toDateString();
|
|
80
85
|
if (isToday) {
|
|
81
86
|
// 当天消息只显示时分
|
|
82
|
-
return date.toLocaleString(
|
|
83
|
-
hour:
|
|
84
|
-
minute:
|
|
87
|
+
return date.toLocaleString("zh-CN", {
|
|
88
|
+
hour: "2-digit",
|
|
89
|
+
minute: "2-digit",
|
|
85
90
|
hour12: false
|
|
86
91
|
});
|
|
87
92
|
} else {
|
|
88
93
|
// 非当天消息显示月日时分
|
|
89
|
-
return date.toLocaleString(
|
|
90
|
-
month:
|
|
91
|
-
day:
|
|
92
|
-
hour:
|
|
93
|
-
minute:
|
|
94
|
+
return date.toLocaleString("zh-CN", {
|
|
95
|
+
month: "2-digit",
|
|
96
|
+
day: "2-digit",
|
|
97
|
+
hour: "2-digit",
|
|
98
|
+
minute: "2-digit",
|
|
94
99
|
hour12: false
|
|
95
100
|
});
|
|
96
101
|
}
|
|
97
102
|
};
|
|
98
103
|
var isMySelf = (msg === null || msg === void 0 ? void 0 : msg.bySelf) === true || (msg === null || msg === void 0 ? void 0 : msg.from.toLowerCase()) === ((_userInfo$uid2 = userInfo.uid) === null || _userInfo$uid2 === void 0 ? void 0 : _userInfo$uid2.toLowerCase());
|
|
99
104
|
return /*#__PURE__*/React.createElement("div", {
|
|
100
|
-
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ?
|
|
105
|
+
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ? "items-end" : "items-start")
|
|
101
106
|
}, /*#__PURE__*/React.createElement("div", {
|
|
102
107
|
style: {
|
|
103
108
|
background: isMySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
@@ -115,7 +120,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
115
120
|
var _renderMessage = function renderMessage(msg) {
|
|
116
121
|
if (msg.type === "txt") {
|
|
117
122
|
return renderTxtMsg(msg);
|
|
118
|
-
} else if (msg.type ===
|
|
123
|
+
} else if (msg.type === "img") {
|
|
119
124
|
return /*#__PURE__*/React.createElement(agoraChatUikit.ImageMessage, {
|
|
120
125
|
reaction: false,
|
|
121
126
|
select: false,
|
|
@@ -130,7 +135,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
130
135
|
},
|
|
131
136
|
imageMessage: msg
|
|
132
137
|
});
|
|
133
|
-
} else if (msg.type ===
|
|
138
|
+
} else if (msg.type === "file") {
|
|
134
139
|
return /*#__PURE__*/React.createElement(agoraChatUikit.FileMessage, {
|
|
135
140
|
bubbleStyle: {
|
|
136
141
|
background: msg.bySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
@@ -151,7 +156,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
151
156
|
},
|
|
152
157
|
fileMessage: msg
|
|
153
158
|
});
|
|
154
|
-
} else if (msg.type ===
|
|
159
|
+
} else if (msg.type === "video") {
|
|
155
160
|
return /*#__PURE__*/React.createElement(agoraChatUikit.VideoMessage, {
|
|
156
161
|
reaction: false,
|
|
157
162
|
select: false,
|
|
@@ -170,7 +175,8 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
170
175
|
return undefined;
|
|
171
176
|
}
|
|
172
177
|
};
|
|
173
|
-
|
|
178
|
+
// 使用 useCallback 包装 getHeaderInfo 函数
|
|
179
|
+
var getHeaderInfo = React.useCallback(function () {
|
|
174
180
|
var _context;
|
|
175
181
|
var cvs = _findInstanceProperty(_context = agoraChatUikit.rootStore.conversationStore.conversationList).call(_context, function (cvs) {
|
|
176
182
|
return cvs.conversationId === props.conversationId;
|
|
@@ -192,9 +198,9 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
192
198
|
if (cvs.conversationId == (group === null || group === void 0 ? void 0 : group.groupid) && group !== null && group !== void 0 && (_group$info = group.info) !== null && _group$info !== void 0 && _group$info.custom) {
|
|
193
199
|
var _group$info2, _customObj$headimgurl, _group$info$affiliati, _group$info3, _ref, _ref2, _group$name, _group$info4;
|
|
194
200
|
var customObj = JSON.parse(group === null || group === void 0 || (_group$info2 = group.info) === null || _group$info2 === void 0 ? void 0 : _group$info2.custom);
|
|
195
|
-
var imageurl = (_customObj$headimgurl = customObj === null || customObj === void 0 ? void 0 : customObj.headimgurl) !== null && _customObj$headimgurl !== void 0 ? _customObj$headimgurl :
|
|
201
|
+
var imageurl = (_customObj$headimgurl = customObj === null || customObj === void 0 ? void 0 : customObj.headimgurl) !== null && _customObj$headimgurl !== void 0 ? _customObj$headimgurl : "";
|
|
196
202
|
var member = (_group$info$affiliati = group === null || group === void 0 || (_group$info3 = group.info) === null || _group$info3 === void 0 ? void 0 : _group$info3.affiliations_count) !== null && _group$info$affiliati !== void 0 ? _group$info$affiliati : 0;
|
|
197
|
-
var name = (_ref = (_ref2 = (_group$name = group === null || group === void 0 ? void 0 : group.name) !== null && _group$name !== void 0 ? _group$name : group === null || group === void 0 || (_group$info4 = group.info) === null || _group$info4 === void 0 ? void 0 : _group$info4.name) !== null && _ref2 !== void 0 ? _ref2 : cvs.name) !== null && _ref !== void 0 ? _ref :
|
|
203
|
+
var name = (_ref = (_ref2 = (_group$name = group === null || group === void 0 ? void 0 : group.name) !== null && _group$name !== void 0 ? _group$name : group === null || group === void 0 || (_group$info4 = group.info) === null || _group$info4 === void 0 ? void 0 : _group$info4.name) !== null && _ref2 !== void 0 ? _ref2 : cvs.name) !== null && _ref !== void 0 ? _ref : "";
|
|
198
204
|
setHeaderInfo(function (prevState) {
|
|
199
205
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
200
206
|
headerImageURL: imageurl,
|
|
@@ -214,8 +220,9 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
214
220
|
agoraChatUikit.rootStore.addressStore.getUserInfo(cvs.conversationId).then(function (value) {
|
|
215
221
|
if (value) {
|
|
216
222
|
var _value$avatarurl, _value$name;
|
|
217
|
-
var imageurl = (_value$avatarurl = value === null || value === void 0 ? void 0 : value.avatarurl) !== null && _value$avatarurl !== void 0 ? _value$avatarurl :
|
|
223
|
+
var imageurl = (_value$avatarurl = value === null || value === void 0 ? void 0 : value.avatarurl) !== null && _value$avatarurl !== void 0 ? _value$avatarurl : "";
|
|
218
224
|
var name = (_value$name = value === null || value === void 0 ? void 0 : value.name) !== null && _value$name !== void 0 ? _value$name : cvs.name;
|
|
225
|
+
console.log("the user info fecthed", name, imageurl);
|
|
219
226
|
setHeaderInfo(function (prevState) {
|
|
220
227
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
221
228
|
headerImageURL: imageurl,
|
|
@@ -226,8 +233,8 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
226
233
|
});
|
|
227
234
|
} else {
|
|
228
235
|
var _appUsersInfo$avataru, _ref3, _appUsersInfo$name;
|
|
229
|
-
var imageurl = (_appUsersInfo$avataru = appUsersInfo === null || appUsersInfo === void 0 ? void 0 : appUsersInfo.avatarurl) !== null && _appUsersInfo$avataru !== void 0 ? _appUsersInfo$avataru :
|
|
230
|
-
var name = (_ref3 = (_appUsersInfo$name = appUsersInfo === null || appUsersInfo === void 0 ? void 0 : appUsersInfo.name) !== null && _appUsersInfo$name !== void 0 ? _appUsersInfo$name : cvs.name) !== null && _ref3 !== void 0 ? _ref3 :
|
|
236
|
+
var imageurl = (_appUsersInfo$avataru = appUsersInfo === null || appUsersInfo === void 0 ? void 0 : appUsersInfo.avatarurl) !== null && _appUsersInfo$avataru !== void 0 ? _appUsersInfo$avataru : "";
|
|
237
|
+
var name = (_ref3 = (_appUsersInfo$name = appUsersInfo === null || appUsersInfo === void 0 ? void 0 : appUsersInfo.name) !== null && _appUsersInfo$name !== void 0 ? _appUsersInfo$name : cvs.name) !== null && _ref3 !== void 0 ? _ref3 : "";
|
|
231
238
|
setHeaderInfo(function (prevState) {
|
|
232
239
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
233
240
|
headerImageURL: imageurl,
|
|
@@ -236,27 +243,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
236
243
|
});
|
|
237
244
|
}
|
|
238
245
|
}
|
|
239
|
-
};
|
|
240
|
-
React.useEffect(function () {
|
|
241
|
-
if (props.conversationId) {
|
|
242
|
-
var _props$chatType;
|
|
243
|
-
var chattype = (_props$chatType = props.chatType) !== null && _props$chatType !== void 0 ? _props$chatType : 'singleChat';
|
|
244
|
-
var conversation = agoraChatUikit.rootStore.conversationStore.getConversation(chattype, props.conversationId);
|
|
245
|
-
if (!conversation) {
|
|
246
|
-
var newConversation = {
|
|
247
|
-
conversationId: props.conversationId,
|
|
248
|
-
chatType: props.chatType,
|
|
249
|
-
lastMessage: {},
|
|
250
|
-
unreadCount: 0
|
|
251
|
-
};
|
|
252
|
-
agoraChatUikit.rootStore.conversationStore.addConversation(newConversation);
|
|
253
|
-
setCurrentConversation(newConversation);
|
|
254
|
-
} else {
|
|
255
|
-
setCurrentConversation(conversation);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
getHeaderInfo();
|
|
259
|
-
}, []);
|
|
246
|
+
}, [props.conversationId]);
|
|
260
247
|
var customHeader = function customHeader() {
|
|
261
248
|
return /*#__PURE__*/React.createElement("div", {
|
|
262
249
|
className: "flex h-16 items-center bg-[var(--im-main-backgroundColor)] border-b border-[var(--im-border-10)] mx-4 justify-between"
|
|
@@ -264,19 +251,66 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
264
251
|
className: "flex items-center gap-4"
|
|
265
252
|
}, /*#__PURE__*/React.createElement("img", {
|
|
266
253
|
src: headerInfo.headerImageURL,
|
|
267
|
-
className: "size-8 ".concat(headerInfo.chatType ===
|
|
254
|
+
className: "size-8 ".concat(headerInfo.chatType === "groupChat" ? "rounded-md" : "rounded-full", " bg-blue")
|
|
268
255
|
}), /*#__PURE__*/React.createElement("div", {
|
|
269
256
|
className: "flex flex-col overflow-hidden flex-1"
|
|
270
257
|
}, /*#__PURE__*/React.createElement("p", {
|
|
271
258
|
className: "text-[var(--im-main-fontColor)] text-[20px] font-bold line-clamp-1 mr-[100px]"
|
|
272
|
-
}, headerInfo.conversationName), headerInfo.chatType ===
|
|
259
|
+
}, headerInfo.conversationName), headerInfo.chatType === "groupChat" && /*#__PURE__*/React.createElement("p", {
|
|
273
260
|
style: {
|
|
274
|
-
color:
|
|
261
|
+
color: "var(--im-third-fontColor)"
|
|
275
262
|
},
|
|
276
263
|
className: "text-sm"
|
|
277
264
|
}, headerInfo.memberCount, " members"))));
|
|
278
265
|
};
|
|
279
|
-
|
|
266
|
+
// First define initConversation with useCallback
|
|
267
|
+
var initConversation = React.useCallback(function () {
|
|
268
|
+
var _props$chatType;
|
|
269
|
+
if (!props.conversationId || !agoraChatUikit.rootStore.loginState) return;
|
|
270
|
+
var chattype = (_props$chatType = props.chatType) !== null && _props$chatType !== void 0 ? _props$chatType : "singleChat";
|
|
271
|
+
var conversation = agoraChatUikit.rootStore.conversationStore.getConversation(chattype, props.conversationId);
|
|
272
|
+
if (!conversation) {
|
|
273
|
+
var newConversation = {
|
|
274
|
+
conversationId: props.conversationId,
|
|
275
|
+
chatType: props.chatType,
|
|
276
|
+
lastMessage: {},
|
|
277
|
+
unreadCount: 0
|
|
278
|
+
};
|
|
279
|
+
agoraChatUikit.rootStore.conversationStore.addConversation(newConversation);
|
|
280
|
+
setCurrentConversation(newConversation);
|
|
281
|
+
} else {
|
|
282
|
+
setCurrentConversation(conversation);
|
|
283
|
+
}
|
|
284
|
+
}, [props.conversationId, props.chatType]);
|
|
285
|
+
// 使用 useEffect 设置初始状态和定期检查登录状态
|
|
286
|
+
React.useEffect(function () {
|
|
287
|
+
console.log("useEffect running", agoraChatUikit.rootStore.loginState);
|
|
288
|
+
// 初始检查登录状态
|
|
289
|
+
var currentLoginState = agoraChatUikit.rootStore.loginState;
|
|
290
|
+
setLoading(!currentLoginState);
|
|
291
|
+
if (currentLoginState && props.conversationId) {
|
|
292
|
+
initConversation();
|
|
293
|
+
getHeaderInfo();
|
|
294
|
+
}
|
|
295
|
+
var intervalId = _setInterval(function () {
|
|
296
|
+
// 如果登录状态发生变化
|
|
297
|
+
console.log("Agora login state:", agoraChatUikit.rootStore.loginState);
|
|
298
|
+
if (agoraChatUikit.rootStore.loginState && props.conversationId) {
|
|
299
|
+
setLoading(!agoraChatUikit.rootStore.loginState);
|
|
300
|
+
clearInterval(intervalId);
|
|
301
|
+
initConversation();
|
|
302
|
+
getHeaderInfo();
|
|
303
|
+
}
|
|
304
|
+
}, 1000); // 每秒检查一次
|
|
305
|
+
// 设置定时器定期检查登录状态
|
|
306
|
+
if (agoraChatUikit.rootStore.loginState) {
|
|
307
|
+
clearInterval(intervalId);
|
|
308
|
+
}
|
|
309
|
+
// 清理函数
|
|
310
|
+
return function () {
|
|
311
|
+
clearInterval(intervalId);
|
|
312
|
+
};
|
|
313
|
+
}, [getHeaderInfo, initConversation, props.conversationId]);
|
|
280
314
|
var handleSendMessage = /*#__PURE__*/function () {
|
|
281
315
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(text) {
|
|
282
316
|
var txtMessage;
|
|
@@ -291,7 +325,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
291
325
|
case 2:
|
|
292
326
|
_context2.prev = 2;
|
|
293
327
|
txtMessage = MessageSDK.message.create({
|
|
294
|
-
type:
|
|
328
|
+
type: "txt",
|
|
295
329
|
msg: text,
|
|
296
330
|
to: props.conversationId,
|
|
297
331
|
// Need to be the user ID of the current conversation
|
|
@@ -306,7 +340,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
306
340
|
case 9:
|
|
307
341
|
_context2.prev = 9;
|
|
308
342
|
_context2.t0 = _context2["catch"](2);
|
|
309
|
-
console.log(
|
|
343
|
+
console.log("send txt message failed", _context2.t0);
|
|
310
344
|
case 12:
|
|
311
345
|
case "end":
|
|
312
346
|
return _context2.stop();
|
|
@@ -334,8 +368,11 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
334
368
|
};
|
|
335
369
|
}();
|
|
336
370
|
return /*#__PURE__*/React.createElement("div", {
|
|
337
|
-
className: "bg-[var(--im-main-backgroundColor)] im-agent-mid ".concat((_props$className = props.className) !== null && _props$className !== void 0 ? _props$className :
|
|
338
|
-
},
|
|
371
|
+
className: "bg-[var(--im-main-backgroundColor)] im-agent-mid ".concat((_props$className = props.className) !== null && _props$className !== void 0 ? _props$className : "", " w-full h-full overflow-hidden flex flex-col")
|
|
372
|
+
}, loading ? /*#__PURE__*/React.createElement("div", {
|
|
373
|
+
className: "flex-1 flex items-center justify-center text-gray-500"
|
|
374
|
+
}, "Loading...") // 显示加载状态
|
|
375
|
+
: /*#__PURE__*/React.createElement(React.Fragment, null, showHeader === true && customHeader(), showHeader === false && currentConversation && props.renderHeader && props.renderHeader(currentConversation), /*#__PURE__*/React.createElement(agoraChatUikit.MessageList, {
|
|
339
376
|
className: "w-full flex-1",
|
|
340
377
|
conversation: {
|
|
341
378
|
conversationId: props.conversationId,
|
|
@@ -347,7 +384,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
347
384
|
messageProps: _objectSpread({}, type.commonMessageProps)
|
|
348
385
|
}), !props.renderInputView && /*#__PURE__*/React.createElement(agoraChatUikit.MessageInput, _extends({
|
|
349
386
|
enabledTyping: true,
|
|
350
|
-
placeHolder:
|
|
387
|
+
placeHolder: "",
|
|
351
388
|
conversation: {
|
|
352
389
|
conversationId: props.conversationId,
|
|
353
390
|
chatType: props.chatType
|
|
@@ -357,7 +394,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
357
394
|
onSendMessage: function onSendMessage(msg) {
|
|
358
395
|
afterSendMsg(msg);
|
|
359
396
|
}
|
|
360
|
-
})), props.renderInputView && currentConversation && props.renderInputView(currentConversation, handleSendMessage));
|
|
397
|
+
})), props.renderInputView && currentConversation && props.renderInputView(currentConversation, handleSendMessage)));
|
|
361
398
|
};
|
|
362
399
|
|
|
363
400
|
module.exports = HighlyCustomChat;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/esm/defineProperty');
|
|
4
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/esm/slicedToArray');
|
|
5
|
+
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
3
6
|
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
4
7
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
5
8
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
@@ -8,10 +11,6 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
|
|
|
8
11
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
9
12
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
10
13
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
11
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/esm/defineProperty');
|
|
12
|
-
var _slicedToArray = require('@babel/runtime-corejs3/helpers/esm/slicedToArray');
|
|
13
|
-
var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
|
|
14
|
-
var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
|
|
15
14
|
var React = require('react');
|
|
16
15
|
require('./style/index.scss');
|
|
17
16
|
var agoraChatUikit = require('agora-chat-uikit');
|
|
@@ -69,11 +68,10 @@ var CustomConversationItem = function CustomConversationItem(props) {
|
|
|
69
68
|
var _res$data$cvs$convers;
|
|
70
69
|
setAvatar(res.data[cvs.conversationId].avatarurl);
|
|
71
70
|
setName(res.data[cvs.conversationId].nickname);
|
|
72
|
-
console.log("the conversation user info is", res.data[cvs.conversationId]);
|
|
73
71
|
if ((_res$data$cvs$convers = res.data[cvs.conversationId]) !== null && _res$data$cvs$convers !== void 0 && _res$data$cvs$convers.ext) {
|
|
74
72
|
var _res$data$cvs$convers2;
|
|
75
|
-
// 修改这里:exe -> ext
|
|
76
73
|
var customObj = JSON.parse((_res$data$cvs$convers2 = res.data[cvs.conversationId]) === null || _res$data$cvs$convers2 === void 0 ? void 0 : _res$data$cvs$convers2.ext);
|
|
74
|
+
// 假设有一个字段 shouldShowInList 来判断是否展示
|
|
77
75
|
setCanShow((customObj === null || customObj === void 0 ? void 0 : customObj.certification) !== "2");
|
|
78
76
|
}
|
|
79
77
|
var tempUserInfo = agoraChatUikit.rootStore.addressStore.appUsersInfo[cvs.conversationId];
|
|
@@ -86,10 +84,9 @@ var CustomConversationItem = function CustomConversationItem(props) {
|
|
|
86
84
|
} else {
|
|
87
85
|
setAvatar(userInfo.avatarurl);
|
|
88
86
|
setName(userInfo.name);
|
|
89
|
-
console.log("the conversation user info is", _JSON$stringify(userInfo));
|
|
90
87
|
if (userInfo !== null && userInfo !== void 0 && userInfo.ext) {
|
|
91
|
-
// 修改这里:exe -> ext
|
|
92
88
|
var customObj = JSON.parse(userInfo.ext);
|
|
89
|
+
// 假设有一个字段 shouldShowInList 来判断是否展示
|
|
93
90
|
setCanShow((customObj === null || customObj === void 0 ? void 0 : customObj.certification) !== "2");
|
|
94
91
|
}
|
|
95
92
|
}
|
|
@@ -12,8 +12,9 @@ import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
|
12
12
|
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
13
13
|
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
14
14
|
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
15
|
+
import _setInterval from '@babel/runtime-corejs3/core-js-stable/set-interval';
|
|
15
16
|
import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
|
|
16
|
-
import React, { useContext, useState, useEffect } from 'react';
|
|
17
|
+
import React, { useContext, useState, useCallback, useEffect } from 'react';
|
|
17
18
|
import { useSDK, rootStore, MessageList, MessageInput, ImageMessage, FileMessage, VideoMessage, BaseMessage } from 'agora-chat-uikit';
|
|
18
19
|
import { Context } from '../IM/context.js';
|
|
19
20
|
import { commonMessageInputConfig, commonMessageProps } from '../type.js';
|
|
@@ -30,29 +31,33 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
30
31
|
var _useContext = useContext(Context);
|
|
31
32
|
_useContext.http;
|
|
32
33
|
var userInfo = _useContext.userInfo;
|
|
33
|
-
var _useState = useState(
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
var _useState = useState(true),
|
|
35
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
+
loading = _useState2[0],
|
|
37
|
+
setLoading = _useState2[1]; // 新增状态用于控制加载
|
|
38
|
+
var _useState3 = useState({
|
|
39
|
+
headerImageURL: "",
|
|
40
|
+
conversationName: "",
|
|
36
41
|
memberCount: 0,
|
|
37
|
-
chatType:
|
|
38
|
-
conversationId:
|
|
42
|
+
chatType: "singleChat",
|
|
43
|
+
conversationId: ""
|
|
39
44
|
}),
|
|
40
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
-
headerInfo = _useState2[0],
|
|
42
|
-
setHeaderInfo = _useState2[1];
|
|
43
|
-
var _useState3 = useState(undefined),
|
|
44
45
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
headerInfo = _useState4[0],
|
|
47
|
+
setHeaderInfo = _useState4[1];
|
|
48
|
+
var _useState5 = useState(undefined),
|
|
49
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
50
|
+
currentConversation = _useState6[0],
|
|
51
|
+
setCurrentConversation = _useState6[1];
|
|
47
52
|
var renderTxtMsg = function renderTxtMsg(msg) {
|
|
48
53
|
var _userInfo$uid;
|
|
49
54
|
var isMySelf = (msg === null || msg === void 0 ? void 0 : msg.bySelf) === true || (msg === null || msg === void 0 ? void 0 : msg.from.toLowerCase()) === ((_userInfo$uid = userInfo.uid) === null || _userInfo$uid === void 0 ? void 0 : _userInfo$uid.toLowerCase());
|
|
50
55
|
return /*#__PURE__*/React.createElement(BaseMessage, {
|
|
51
|
-
bubbleType:
|
|
56
|
+
bubbleType: "none",
|
|
52
57
|
reaction: false,
|
|
53
58
|
select: false,
|
|
54
59
|
thread: false,
|
|
55
|
-
direction: isMySelf ?
|
|
60
|
+
direction: isMySelf ? "rtl" : "ltr",
|
|
56
61
|
renderUserProfile: function renderUserProfile() {
|
|
57
62
|
return null;
|
|
58
63
|
},
|
|
@@ -70,32 +75,32 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
70
75
|
var _userInfo$uid2;
|
|
71
76
|
// 格式化消息时间
|
|
72
77
|
var formatMessageTime = function formatMessageTime(timestamp) {
|
|
73
|
-
if (!timestamp) return
|
|
78
|
+
if (!timestamp) return "";
|
|
74
79
|
var date = new Date(timestamp);
|
|
75
80
|
var now = new Date();
|
|
76
81
|
// 判断是否是同一天
|
|
77
82
|
var isToday = date.toDateString() === now.toDateString();
|
|
78
83
|
if (isToday) {
|
|
79
84
|
// 当天消息只显示时分
|
|
80
|
-
return date.toLocaleString(
|
|
81
|
-
hour:
|
|
82
|
-
minute:
|
|
85
|
+
return date.toLocaleString("zh-CN", {
|
|
86
|
+
hour: "2-digit",
|
|
87
|
+
minute: "2-digit",
|
|
83
88
|
hour12: false
|
|
84
89
|
});
|
|
85
90
|
} else {
|
|
86
91
|
// 非当天消息显示月日时分
|
|
87
|
-
return date.toLocaleString(
|
|
88
|
-
month:
|
|
89
|
-
day:
|
|
90
|
-
hour:
|
|
91
|
-
minute:
|
|
92
|
+
return date.toLocaleString("zh-CN", {
|
|
93
|
+
month: "2-digit",
|
|
94
|
+
day: "2-digit",
|
|
95
|
+
hour: "2-digit",
|
|
96
|
+
minute: "2-digit",
|
|
92
97
|
hour12: false
|
|
93
98
|
});
|
|
94
99
|
}
|
|
95
100
|
};
|
|
96
101
|
var isMySelf = (msg === null || msg === void 0 ? void 0 : msg.bySelf) === true || (msg === null || msg === void 0 ? void 0 : msg.from.toLowerCase()) === ((_userInfo$uid2 = userInfo.uid) === null || _userInfo$uid2 === void 0 ? void 0 : _userInfo$uid2.toLowerCase());
|
|
97
102
|
return /*#__PURE__*/React.createElement("div", {
|
|
98
|
-
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ?
|
|
103
|
+
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ? "items-end" : "items-start")
|
|
99
104
|
}, /*#__PURE__*/React.createElement("div", {
|
|
100
105
|
style: {
|
|
101
106
|
background: isMySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
@@ -113,7 +118,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
113
118
|
var _renderMessage = function renderMessage(msg) {
|
|
114
119
|
if (msg.type === "txt") {
|
|
115
120
|
return renderTxtMsg(msg);
|
|
116
|
-
} else if (msg.type ===
|
|
121
|
+
} else if (msg.type === "img") {
|
|
117
122
|
return /*#__PURE__*/React.createElement(ImageMessage, {
|
|
118
123
|
reaction: false,
|
|
119
124
|
select: false,
|
|
@@ -128,7 +133,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
128
133
|
},
|
|
129
134
|
imageMessage: msg
|
|
130
135
|
});
|
|
131
|
-
} else if (msg.type ===
|
|
136
|
+
} else if (msg.type === "file") {
|
|
132
137
|
return /*#__PURE__*/React.createElement(FileMessage, {
|
|
133
138
|
bubbleStyle: {
|
|
134
139
|
background: msg.bySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
@@ -149,7 +154,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
149
154
|
},
|
|
150
155
|
fileMessage: msg
|
|
151
156
|
});
|
|
152
|
-
} else if (msg.type ===
|
|
157
|
+
} else if (msg.type === "video") {
|
|
153
158
|
return /*#__PURE__*/React.createElement(VideoMessage, {
|
|
154
159
|
reaction: false,
|
|
155
160
|
select: false,
|
|
@@ -168,7 +173,8 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
168
173
|
return undefined;
|
|
169
174
|
}
|
|
170
175
|
};
|
|
171
|
-
|
|
176
|
+
// 使用 useCallback 包装 getHeaderInfo 函数
|
|
177
|
+
var getHeaderInfo = useCallback(function () {
|
|
172
178
|
var _context;
|
|
173
179
|
var cvs = _findInstanceProperty(_context = rootStore.conversationStore.conversationList).call(_context, function (cvs) {
|
|
174
180
|
return cvs.conversationId === props.conversationId;
|
|
@@ -190,9 +196,9 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
190
196
|
if (cvs.conversationId == (group === null || group === void 0 ? void 0 : group.groupid) && group !== null && group !== void 0 && (_group$info = group.info) !== null && _group$info !== void 0 && _group$info.custom) {
|
|
191
197
|
var _group$info2, _customObj$headimgurl, _group$info$affiliati, _group$info3, _ref, _ref2, _group$name, _group$info4;
|
|
192
198
|
var customObj = JSON.parse(group === null || group === void 0 || (_group$info2 = group.info) === null || _group$info2 === void 0 ? void 0 : _group$info2.custom);
|
|
193
|
-
var imageurl = (_customObj$headimgurl = customObj === null || customObj === void 0 ? void 0 : customObj.headimgurl) !== null && _customObj$headimgurl !== void 0 ? _customObj$headimgurl :
|
|
199
|
+
var imageurl = (_customObj$headimgurl = customObj === null || customObj === void 0 ? void 0 : customObj.headimgurl) !== null && _customObj$headimgurl !== void 0 ? _customObj$headimgurl : "";
|
|
194
200
|
var member = (_group$info$affiliati = group === null || group === void 0 || (_group$info3 = group.info) === null || _group$info3 === void 0 ? void 0 : _group$info3.affiliations_count) !== null && _group$info$affiliati !== void 0 ? _group$info$affiliati : 0;
|
|
195
|
-
var name = (_ref = (_ref2 = (_group$name = group === null || group === void 0 ? void 0 : group.name) !== null && _group$name !== void 0 ? _group$name : group === null || group === void 0 || (_group$info4 = group.info) === null || _group$info4 === void 0 ? void 0 : _group$info4.name) !== null && _ref2 !== void 0 ? _ref2 : cvs.name) !== null && _ref !== void 0 ? _ref :
|
|
201
|
+
var name = (_ref = (_ref2 = (_group$name = group === null || group === void 0 ? void 0 : group.name) !== null && _group$name !== void 0 ? _group$name : group === null || group === void 0 || (_group$info4 = group.info) === null || _group$info4 === void 0 ? void 0 : _group$info4.name) !== null && _ref2 !== void 0 ? _ref2 : cvs.name) !== null && _ref !== void 0 ? _ref : "";
|
|
196
202
|
setHeaderInfo(function (prevState) {
|
|
197
203
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
198
204
|
headerImageURL: imageurl,
|
|
@@ -212,8 +218,9 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
212
218
|
rootStore.addressStore.getUserInfo(cvs.conversationId).then(function (value) {
|
|
213
219
|
if (value) {
|
|
214
220
|
var _value$avatarurl, _value$name;
|
|
215
|
-
var imageurl = (_value$avatarurl = value === null || value === void 0 ? void 0 : value.avatarurl) !== null && _value$avatarurl !== void 0 ? _value$avatarurl :
|
|
221
|
+
var imageurl = (_value$avatarurl = value === null || value === void 0 ? void 0 : value.avatarurl) !== null && _value$avatarurl !== void 0 ? _value$avatarurl : "";
|
|
216
222
|
var name = (_value$name = value === null || value === void 0 ? void 0 : value.name) !== null && _value$name !== void 0 ? _value$name : cvs.name;
|
|
223
|
+
console.log("the user info fecthed", name, imageurl);
|
|
217
224
|
setHeaderInfo(function (prevState) {
|
|
218
225
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
219
226
|
headerImageURL: imageurl,
|
|
@@ -224,8 +231,8 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
224
231
|
});
|
|
225
232
|
} else {
|
|
226
233
|
var _appUsersInfo$avataru, _ref3, _appUsersInfo$name;
|
|
227
|
-
var imageurl = (_appUsersInfo$avataru = appUsersInfo === null || appUsersInfo === void 0 ? void 0 : appUsersInfo.avatarurl) !== null && _appUsersInfo$avataru !== void 0 ? _appUsersInfo$avataru :
|
|
228
|
-
var name = (_ref3 = (_appUsersInfo$name = appUsersInfo === null || appUsersInfo === void 0 ? void 0 : appUsersInfo.name) !== null && _appUsersInfo$name !== void 0 ? _appUsersInfo$name : cvs.name) !== null && _ref3 !== void 0 ? _ref3 :
|
|
234
|
+
var imageurl = (_appUsersInfo$avataru = appUsersInfo === null || appUsersInfo === void 0 ? void 0 : appUsersInfo.avatarurl) !== null && _appUsersInfo$avataru !== void 0 ? _appUsersInfo$avataru : "";
|
|
235
|
+
var name = (_ref3 = (_appUsersInfo$name = appUsersInfo === null || appUsersInfo === void 0 ? void 0 : appUsersInfo.name) !== null && _appUsersInfo$name !== void 0 ? _appUsersInfo$name : cvs.name) !== null && _ref3 !== void 0 ? _ref3 : "";
|
|
229
236
|
setHeaderInfo(function (prevState) {
|
|
230
237
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
231
238
|
headerImageURL: imageurl,
|
|
@@ -234,27 +241,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
234
241
|
});
|
|
235
242
|
}
|
|
236
243
|
}
|
|
237
|
-
};
|
|
238
|
-
useEffect(function () {
|
|
239
|
-
if (props.conversationId) {
|
|
240
|
-
var _props$chatType;
|
|
241
|
-
var chattype = (_props$chatType = props.chatType) !== null && _props$chatType !== void 0 ? _props$chatType : 'singleChat';
|
|
242
|
-
var conversation = rootStore.conversationStore.getConversation(chattype, props.conversationId);
|
|
243
|
-
if (!conversation) {
|
|
244
|
-
var newConversation = {
|
|
245
|
-
conversationId: props.conversationId,
|
|
246
|
-
chatType: props.chatType,
|
|
247
|
-
lastMessage: {},
|
|
248
|
-
unreadCount: 0
|
|
249
|
-
};
|
|
250
|
-
rootStore.conversationStore.addConversation(newConversation);
|
|
251
|
-
setCurrentConversation(newConversation);
|
|
252
|
-
} else {
|
|
253
|
-
setCurrentConversation(conversation);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
getHeaderInfo();
|
|
257
|
-
}, []);
|
|
244
|
+
}, [props.conversationId]);
|
|
258
245
|
var customHeader = function customHeader() {
|
|
259
246
|
return /*#__PURE__*/React.createElement("div", {
|
|
260
247
|
className: "flex h-16 items-center bg-[var(--im-main-backgroundColor)] border-b border-[var(--im-border-10)] mx-4 justify-between"
|
|
@@ -262,19 +249,66 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
262
249
|
className: "flex items-center gap-4"
|
|
263
250
|
}, /*#__PURE__*/React.createElement("img", {
|
|
264
251
|
src: headerInfo.headerImageURL,
|
|
265
|
-
className: "size-8 ".concat(headerInfo.chatType ===
|
|
252
|
+
className: "size-8 ".concat(headerInfo.chatType === "groupChat" ? "rounded-md" : "rounded-full", " bg-blue")
|
|
266
253
|
}), /*#__PURE__*/React.createElement("div", {
|
|
267
254
|
className: "flex flex-col overflow-hidden flex-1"
|
|
268
255
|
}, /*#__PURE__*/React.createElement("p", {
|
|
269
256
|
className: "text-[var(--im-main-fontColor)] text-[20px] font-bold line-clamp-1 mr-[100px]"
|
|
270
|
-
}, headerInfo.conversationName), headerInfo.chatType ===
|
|
257
|
+
}, headerInfo.conversationName), headerInfo.chatType === "groupChat" && /*#__PURE__*/React.createElement("p", {
|
|
271
258
|
style: {
|
|
272
|
-
color:
|
|
259
|
+
color: "var(--im-third-fontColor)"
|
|
273
260
|
},
|
|
274
261
|
className: "text-sm"
|
|
275
262
|
}, headerInfo.memberCount, " members"))));
|
|
276
263
|
};
|
|
277
|
-
|
|
264
|
+
// First define initConversation with useCallback
|
|
265
|
+
var initConversation = useCallback(function () {
|
|
266
|
+
var _props$chatType;
|
|
267
|
+
if (!props.conversationId || !rootStore.loginState) return;
|
|
268
|
+
var chattype = (_props$chatType = props.chatType) !== null && _props$chatType !== void 0 ? _props$chatType : "singleChat";
|
|
269
|
+
var conversation = rootStore.conversationStore.getConversation(chattype, props.conversationId);
|
|
270
|
+
if (!conversation) {
|
|
271
|
+
var newConversation = {
|
|
272
|
+
conversationId: props.conversationId,
|
|
273
|
+
chatType: props.chatType,
|
|
274
|
+
lastMessage: {},
|
|
275
|
+
unreadCount: 0
|
|
276
|
+
};
|
|
277
|
+
rootStore.conversationStore.addConversation(newConversation);
|
|
278
|
+
setCurrentConversation(newConversation);
|
|
279
|
+
} else {
|
|
280
|
+
setCurrentConversation(conversation);
|
|
281
|
+
}
|
|
282
|
+
}, [props.conversationId, props.chatType]);
|
|
283
|
+
// 使用 useEffect 设置初始状态和定期检查登录状态
|
|
284
|
+
useEffect(function () {
|
|
285
|
+
console.log("useEffect running", rootStore.loginState);
|
|
286
|
+
// 初始检查登录状态
|
|
287
|
+
var currentLoginState = rootStore.loginState;
|
|
288
|
+
setLoading(!currentLoginState);
|
|
289
|
+
if (currentLoginState && props.conversationId) {
|
|
290
|
+
initConversation();
|
|
291
|
+
getHeaderInfo();
|
|
292
|
+
}
|
|
293
|
+
var intervalId = _setInterval(function () {
|
|
294
|
+
// 如果登录状态发生变化
|
|
295
|
+
console.log("Agora login state:", rootStore.loginState);
|
|
296
|
+
if (rootStore.loginState && props.conversationId) {
|
|
297
|
+
setLoading(!rootStore.loginState);
|
|
298
|
+
clearInterval(intervalId);
|
|
299
|
+
initConversation();
|
|
300
|
+
getHeaderInfo();
|
|
301
|
+
}
|
|
302
|
+
}, 1000); // 每秒检查一次
|
|
303
|
+
// 设置定时器定期检查登录状态
|
|
304
|
+
if (rootStore.loginState) {
|
|
305
|
+
clearInterval(intervalId);
|
|
306
|
+
}
|
|
307
|
+
// 清理函数
|
|
308
|
+
return function () {
|
|
309
|
+
clearInterval(intervalId);
|
|
310
|
+
};
|
|
311
|
+
}, [getHeaderInfo, initConversation, props.conversationId]);
|
|
278
312
|
var handleSendMessage = /*#__PURE__*/function () {
|
|
279
313
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(text) {
|
|
280
314
|
var txtMessage;
|
|
@@ -289,7 +323,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
289
323
|
case 2:
|
|
290
324
|
_context2.prev = 2;
|
|
291
325
|
txtMessage = MessageSDK.message.create({
|
|
292
|
-
type:
|
|
326
|
+
type: "txt",
|
|
293
327
|
msg: text,
|
|
294
328
|
to: props.conversationId,
|
|
295
329
|
// Need to be the user ID of the current conversation
|
|
@@ -304,7 +338,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
304
338
|
case 9:
|
|
305
339
|
_context2.prev = 9;
|
|
306
340
|
_context2.t0 = _context2["catch"](2);
|
|
307
|
-
console.log(
|
|
341
|
+
console.log("send txt message failed", _context2.t0);
|
|
308
342
|
case 12:
|
|
309
343
|
case "end":
|
|
310
344
|
return _context2.stop();
|
|
@@ -332,8 +366,11 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
332
366
|
};
|
|
333
367
|
}();
|
|
334
368
|
return /*#__PURE__*/React.createElement("div", {
|
|
335
|
-
className: "bg-[var(--im-main-backgroundColor)] im-agent-mid ".concat((_props$className = props.className) !== null && _props$className !== void 0 ? _props$className :
|
|
336
|
-
},
|
|
369
|
+
className: "bg-[var(--im-main-backgroundColor)] im-agent-mid ".concat((_props$className = props.className) !== null && _props$className !== void 0 ? _props$className : "", " w-full h-full overflow-hidden flex flex-col")
|
|
370
|
+
}, loading ? /*#__PURE__*/React.createElement("div", {
|
|
371
|
+
className: "flex-1 flex items-center justify-center text-gray-500"
|
|
372
|
+
}, "Loading...") // 显示加载状态
|
|
373
|
+
: /*#__PURE__*/React.createElement(React.Fragment, null, showHeader === true && customHeader(), showHeader === false && currentConversation && props.renderHeader && props.renderHeader(currentConversation), /*#__PURE__*/React.createElement(MessageList, {
|
|
337
374
|
className: "w-full flex-1",
|
|
338
375
|
conversation: {
|
|
339
376
|
conversationId: props.conversationId,
|
|
@@ -345,7 +382,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
345
382
|
messageProps: _objectSpread({}, commonMessageProps)
|
|
346
383
|
}), !props.renderInputView && /*#__PURE__*/React.createElement(MessageInput, _extends({
|
|
347
384
|
enabledTyping: true,
|
|
348
|
-
placeHolder:
|
|
385
|
+
placeHolder: "",
|
|
349
386
|
conversation: {
|
|
350
387
|
conversationId: props.conversationId,
|
|
351
388
|
chatType: props.chatType
|
|
@@ -355,7 +392,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
355
392
|
onSendMessage: function onSendMessage(msg) {
|
|
356
393
|
afterSendMsg(msg);
|
|
357
394
|
}
|
|
358
|
-
})), props.renderInputView && currentConversation && props.renderInputView(currentConversation, handleSendMessage));
|
|
395
|
+
})), props.renderInputView && currentConversation && props.renderInputView(currentConversation, handleSendMessage)));
|
|
359
396
|
};
|
|
360
397
|
|
|
361
398
|
export { HighlyCustomChat as default };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
2
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
3
|
+
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
1
4
|
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
2
5
|
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
3
6
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
@@ -6,10 +9,6 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/inst
|
|
|
6
9
|
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
7
10
|
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
8
11
|
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
10
|
-
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
11
|
-
import _findInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/find';
|
|
12
|
-
import _JSON$stringify from '@babel/runtime-corejs3/core-js-stable/json/stringify';
|
|
13
12
|
import React, { useContext, useState, useEffect } from 'react';
|
|
14
13
|
import './style/index.scss';
|
|
15
14
|
import { useConversationContext, useClient, rootStore, ConversationItem, Avatar } from 'agora-chat-uikit';
|
|
@@ -67,11 +66,10 @@ var CustomConversationItem = function CustomConversationItem(props) {
|
|
|
67
66
|
var _res$data$cvs$convers;
|
|
68
67
|
setAvatar(res.data[cvs.conversationId].avatarurl);
|
|
69
68
|
setName(res.data[cvs.conversationId].nickname);
|
|
70
|
-
console.log("the conversation user info is", res.data[cvs.conversationId]);
|
|
71
69
|
if ((_res$data$cvs$convers = res.data[cvs.conversationId]) !== null && _res$data$cvs$convers !== void 0 && _res$data$cvs$convers.ext) {
|
|
72
70
|
var _res$data$cvs$convers2;
|
|
73
|
-
// 修改这里:exe -> ext
|
|
74
71
|
var customObj = JSON.parse((_res$data$cvs$convers2 = res.data[cvs.conversationId]) === null || _res$data$cvs$convers2 === void 0 ? void 0 : _res$data$cvs$convers2.ext);
|
|
72
|
+
// 假设有一个字段 shouldShowInList 来判断是否展示
|
|
75
73
|
setCanShow((customObj === null || customObj === void 0 ? void 0 : customObj.certification) !== "2");
|
|
76
74
|
}
|
|
77
75
|
var tempUserInfo = rootStore.addressStore.appUsersInfo[cvs.conversationId];
|
|
@@ -84,10 +82,9 @@ var CustomConversationItem = function CustomConversationItem(props) {
|
|
|
84
82
|
} else {
|
|
85
83
|
setAvatar(userInfo.avatarurl);
|
|
86
84
|
setName(userInfo.name);
|
|
87
|
-
console.log("the conversation user info is", _JSON$stringify(userInfo));
|
|
88
85
|
if (userInfo !== null && userInfo !== void 0 && userInfo.ext) {
|
|
89
|
-
// 修改这里:exe -> ext
|
|
90
86
|
var customObj = JSON.parse(userInfo.ext);
|
|
87
|
+
// 假设有一个字段 shouldShowInList 来判断是否展示
|
|
91
88
|
setCanShow((customObj === null || customObj === void 0 ? void 0 : customObj.certification) !== "2");
|
|
92
89
|
}
|
|
93
90
|
}
|