whyuzeim 1.0.18 → 1.0.19

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.
@@ -119,14 +119,30 @@ var CustomChatView = function CustomChatView(props) {
119
119
  var renderLongTextMsg = function renderLongTextMsg(msg) {
120
120
  var _userInfo$uid2;
121
121
  // 格式化消息时间
122
+ // 格式化消息时间
122
123
  var formatMessageTime = function formatMessageTime(timestamp) {
123
124
  if (!timestamp) return '';
124
125
  var date = new Date(timestamp);
125
- return date.toLocaleString('zh-CN', {
126
- hour: '2-digit',
127
- minute: '2-digit',
128
- hour12: false
129
- });
126
+ var now = new Date();
127
+ // 判断是否是同一天
128
+ var isToday = date.toDateString() === now.toDateString();
129
+ if (isToday) {
130
+ // 当天消息只显示时分
131
+ return date.toLocaleString('zh-CN', {
132
+ hour: '2-digit',
133
+ minute: '2-digit',
134
+ hour12: false
135
+ });
136
+ } else {
137
+ // 非当天消息显示月日时分
138
+ return date.toLocaleString('zh-CN', {
139
+ month: '2-digit',
140
+ day: '2-digit',
141
+ hour: '2-digit',
142
+ minute: '2-digit',
143
+ hour12: false
144
+ });
145
+ }
130
146
  };
131
147
  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());
132
148
  return /*#__PURE__*/React.createElement("div", {
@@ -74,11 +74,26 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
74
74
  var formatMessageTime = function formatMessageTime(timestamp) {
75
75
  if (!timestamp) return '';
76
76
  var date = new Date(timestamp);
77
- return date.toLocaleString('zh-CN', {
78
- hour: '2-digit',
79
- minute: '2-digit',
80
- hour12: false
81
- });
77
+ var now = new Date();
78
+ // 判断是否是同一天
79
+ var isToday = date.toDateString() === now.toDateString();
80
+ if (isToday) {
81
+ // 当天消息只显示时分
82
+ return date.toLocaleString('zh-CN', {
83
+ hour: '2-digit',
84
+ minute: '2-digit',
85
+ hour12: false
86
+ });
87
+ } else {
88
+ // 非当天消息显示月日时分
89
+ return date.toLocaleString('zh-CN', {
90
+ month: '2-digit',
91
+ day: '2-digit',
92
+ hour: '2-digit',
93
+ minute: '2-digit',
94
+ hour12: false
95
+ });
96
+ }
82
97
  };
83
98
  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());
84
99
  return /*#__PURE__*/React.createElement("div", {
@@ -1,8 +1,5 @@
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');
6
3
  var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
7
4
  var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
8
5
  var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
@@ -11,6 +8,10 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
11
8
  var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
12
9
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
13
10
  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');
14
15
  var React = require('react');
15
16
  require('./style/index.scss');
16
17
  var agoraChatUikit = require('agora-chat-uikit');
@@ -34,6 +35,10 @@ var CustomConversationItem = function CustomConversationItem(props) {
34
35
  setName = _useState4[1];
35
36
  var _useConversationConte = agoraChatUikit.useConversationContext(),
36
37
  setCurrentConversation = _useConversationConte.setCurrentConversation;
38
+ var _useState5 = React.useState(true),
39
+ _useState6 = _slicedToArray(_useState5, 2),
40
+ canShow = _useState6[0],
41
+ setCanShow = _useState6[1];
37
42
  var client = agoraChatUikit.useClient();
38
43
  cvs.chatType === "groupChat" && agoraChatUikit.rootStore.addressStore.getGroupInfo(cvs.conversationId);
39
44
  React.useEffect(function () {
@@ -61,8 +66,16 @@ var CustomConversationItem = function CustomConversationItem(props) {
61
66
  var userInfo = agoraChatUikit.rootStore.addressStore.appUsersInfo[cvs.conversationId];
62
67
  if (!userInfo || !userInfo.avatarurl || !userInfo.name) {
63
68
  client.fetchUserInfoById([cvs.conversationId], ["nickname", "avatarurl", "mail", "phone", "gender", "sign", "birth", "ext"]).then(function (res) {
69
+ var _res$data$cvs$convers;
64
70
  setAvatar(res.data[cvs.conversationId].avatarurl);
65
71
  setName(res.data[cvs.conversationId].nickname);
72
+ console.log("the conversation user info is", res.data[cvs.conversationId]);
73
+ if ((_res$data$cvs$convers = res.data[cvs.conversationId]) !== null && _res$data$cvs$convers !== void 0 && _res$data$cvs$convers.ext) {
74
+ var _res$data$cvs$convers2;
75
+ // 修改这里:exe -> ext
76
+ 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);
77
+ setCanShow((customObj === null || customObj === void 0 ? void 0 : customObj.certification) !== "2");
78
+ }
66
79
  var tempUserInfo = agoraChatUikit.rootStore.addressStore.appUsersInfo[cvs.conversationId];
67
80
  agoraChatUikit.rootStore.addressStore.appUsersInfo[cvs.conversationId] = _objectSpread(_objectSpread({}, tempUserInfo || {}), {}, {
68
81
  userId: cvs.conversationId,
@@ -73,10 +86,16 @@ var CustomConversationItem = function CustomConversationItem(props) {
73
86
  } else {
74
87
  setAvatar(userInfo.avatarurl);
75
88
  setName(userInfo.name);
89
+ console.log("the conversation user info is", _JSON$stringify(userInfo));
90
+ if (userInfo !== null && userInfo !== void 0 && userInfo.ext) {
91
+ // 修改这里:exe -> ext
92
+ var customObj = JSON.parse(userInfo.ext);
93
+ setCanShow((customObj === null || customObj === void 0 ? void 0 : customObj.certification) !== "2");
94
+ }
76
95
  }
77
96
  }
78
97
  }, [client, cvs, cvs.chatType, cvs.conversationId, http]);
79
- return /*#__PURE__*/React.createElement(agoraChatUikit.ConversationItem, {
98
+ return canShow ? /*#__PURE__*/React.createElement(agoraChatUikit.ConversationItem, {
80
99
  className: "yuze-conversationItem",
81
100
  avatar: /*#__PURE__*/React.createElement("div", {
82
101
  className: "yuze-conversationItem-avatar relative"
@@ -105,7 +124,7 @@ var CustomConversationItem = function CustomConversationItem(props) {
105
124
  _onClick && _onClick();
106
125
  setCurrentConversation(_objectSpread({}, cvs));
107
126
  }
108
- });
127
+ }) : null;
109
128
  };
110
129
 
111
130
  module.exports = CustomConversationItem;
@@ -117,14 +117,30 @@ var CustomChatView = function CustomChatView(props) {
117
117
  var renderLongTextMsg = function renderLongTextMsg(msg) {
118
118
  var _userInfo$uid2;
119
119
  // 格式化消息时间
120
+ // 格式化消息时间
120
121
  var formatMessageTime = function formatMessageTime(timestamp) {
121
122
  if (!timestamp) return '';
122
123
  var date = new Date(timestamp);
123
- return date.toLocaleString('zh-CN', {
124
- hour: '2-digit',
125
- minute: '2-digit',
126
- hour12: false
127
- });
124
+ var now = new Date();
125
+ // 判断是否是同一天
126
+ var isToday = date.toDateString() === now.toDateString();
127
+ if (isToday) {
128
+ // 当天消息只显示时分
129
+ return date.toLocaleString('zh-CN', {
130
+ hour: '2-digit',
131
+ minute: '2-digit',
132
+ hour12: false
133
+ });
134
+ } else {
135
+ // 非当天消息显示月日时分
136
+ return date.toLocaleString('zh-CN', {
137
+ month: '2-digit',
138
+ day: '2-digit',
139
+ hour: '2-digit',
140
+ minute: '2-digit',
141
+ hour12: false
142
+ });
143
+ }
128
144
  };
129
145
  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());
130
146
  return /*#__PURE__*/React.createElement("div", {
@@ -72,11 +72,26 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
72
72
  var formatMessageTime = function formatMessageTime(timestamp) {
73
73
  if (!timestamp) return '';
74
74
  var date = new Date(timestamp);
75
- return date.toLocaleString('zh-CN', {
76
- hour: '2-digit',
77
- minute: '2-digit',
78
- hour12: false
79
- });
75
+ var now = new Date();
76
+ // 判断是否是同一天
77
+ var isToday = date.toDateString() === now.toDateString();
78
+ if (isToday) {
79
+ // 当天消息只显示时分
80
+ return date.toLocaleString('zh-CN', {
81
+ hour: '2-digit',
82
+ minute: '2-digit',
83
+ hour12: false
84
+ });
85
+ } else {
86
+ // 非当天消息显示月日时分
87
+ return date.toLocaleString('zh-CN', {
88
+ month: '2-digit',
89
+ day: '2-digit',
90
+ hour: '2-digit',
91
+ minute: '2-digit',
92
+ hour12: false
93
+ });
94
+ }
80
95
  };
81
96
  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());
82
97
  return /*#__PURE__*/React.createElement("div", {
@@ -1,6 +1,3 @@
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';
4
1
  import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
5
2
  import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
6
3
  import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
@@ -9,6 +6,10 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/inst
9
6
  import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
10
7
  import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
11
8
  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';
12
13
  import React, { useContext, useState, useEffect } from 'react';
13
14
  import './style/index.scss';
14
15
  import { useConversationContext, useClient, rootStore, ConversationItem, Avatar } from 'agora-chat-uikit';
@@ -32,6 +33,10 @@ var CustomConversationItem = function CustomConversationItem(props) {
32
33
  setName = _useState4[1];
33
34
  var _useConversationConte = useConversationContext(),
34
35
  setCurrentConversation = _useConversationConte.setCurrentConversation;
36
+ var _useState5 = useState(true),
37
+ _useState6 = _slicedToArray(_useState5, 2),
38
+ canShow = _useState6[0],
39
+ setCanShow = _useState6[1];
35
40
  var client = useClient();
36
41
  cvs.chatType === "groupChat" && rootStore.addressStore.getGroupInfo(cvs.conversationId);
37
42
  useEffect(function () {
@@ -59,8 +64,16 @@ var CustomConversationItem = function CustomConversationItem(props) {
59
64
  var userInfo = rootStore.addressStore.appUsersInfo[cvs.conversationId];
60
65
  if (!userInfo || !userInfo.avatarurl || !userInfo.name) {
61
66
  client.fetchUserInfoById([cvs.conversationId], ["nickname", "avatarurl", "mail", "phone", "gender", "sign", "birth", "ext"]).then(function (res) {
67
+ var _res$data$cvs$convers;
62
68
  setAvatar(res.data[cvs.conversationId].avatarurl);
63
69
  setName(res.data[cvs.conversationId].nickname);
70
+ console.log("the conversation user info is", res.data[cvs.conversationId]);
71
+ if ((_res$data$cvs$convers = res.data[cvs.conversationId]) !== null && _res$data$cvs$convers !== void 0 && _res$data$cvs$convers.ext) {
72
+ var _res$data$cvs$convers2;
73
+ // 修改这里:exe -> ext
74
+ 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);
75
+ setCanShow((customObj === null || customObj === void 0 ? void 0 : customObj.certification) !== "2");
76
+ }
64
77
  var tempUserInfo = rootStore.addressStore.appUsersInfo[cvs.conversationId];
65
78
  rootStore.addressStore.appUsersInfo[cvs.conversationId] = _objectSpread(_objectSpread({}, tempUserInfo || {}), {}, {
66
79
  userId: cvs.conversationId,
@@ -71,10 +84,16 @@ var CustomConversationItem = function CustomConversationItem(props) {
71
84
  } else {
72
85
  setAvatar(userInfo.avatarurl);
73
86
  setName(userInfo.name);
87
+ console.log("the conversation user info is", _JSON$stringify(userInfo));
88
+ if (userInfo !== null && userInfo !== void 0 && userInfo.ext) {
89
+ // 修改这里:exe -> ext
90
+ var customObj = JSON.parse(userInfo.ext);
91
+ setCanShow((customObj === null || customObj === void 0 ? void 0 : customObj.certification) !== "2");
92
+ }
74
93
  }
75
94
  }
76
95
  }, [client, cvs, cvs.chatType, cvs.conversationId, http]);
77
- return /*#__PURE__*/React.createElement(ConversationItem, {
96
+ return canShow ? /*#__PURE__*/React.createElement(ConversationItem, {
78
97
  className: "yuze-conversationItem",
79
98
  avatar: /*#__PURE__*/React.createElement("div", {
80
99
  className: "yuze-conversationItem-avatar relative"
@@ -103,7 +122,7 @@ var CustomConversationItem = function CustomConversationItem(props) {
103
122
  _onClick && _onClick();
104
123
  setCurrentConversation(_objectSpread({}, cvs));
105
124
  }
106
- });
125
+ }) : null;
107
126
  };
108
127
 
109
128
  export { CustomConversationItem as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whyuzeim",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "im componenets",
5
5
  "main": "cjs/index.js",
6
6
  "module": "es/index.js",