1 | import PropTypes from 'prop-types';
|
2 | import dayjs from 'dayjs';
|
3 | export const StylePropType = PropTypes.oneOfType([
|
4 | PropTypes.array,
|
5 | PropTypes.object,
|
6 | PropTypes.number,
|
7 | PropTypes.bool,
|
8 | ]);
|
9 | export function isSameDay(currentMessage, diffMessage) {
|
10 | if (!diffMessage || !diffMessage.createdAt) {
|
11 | return false;
|
12 | }
|
13 | const currentCreatedAt = dayjs(currentMessage.createdAt);
|
14 | const diffCreatedAt = dayjs(diffMessage.createdAt);
|
15 | if (!currentCreatedAt.isValid() || !diffCreatedAt.isValid()) {
|
16 | return false;
|
17 | }
|
18 | return currentCreatedAt.isSame(diffCreatedAt, 'day');
|
19 | }
|
20 | export function isSameUser(currentMessage, diffMessage) {
|
21 | return !!(diffMessage &&
|
22 | diffMessage.user &&
|
23 | currentMessage.user &&
|
24 | diffMessage.user._id === currentMessage.user._id);
|
25 | }
|
26 | const styleString = (color) => `color: ${color}; font-weight: bold`;
|
27 | const headerLog = '%c[react-native-gifted-chat]';
|
28 | export const warning = (...args) => console.log(headerLog, styleString('orange'), ...args);
|
29 | export const error = (...args) => console.log(headerLog, styleString('red'), ...args);
|
30 |
|
\ | No newline at end of file |