Skip to content
This repository was archived by the owner on Jun 16, 2023. It is now read-only.

Commit d305eb8

Browse files
custom status fix
1 parent de4b51d commit d305eb8

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/app/molecules/people-selector/PeopleSelector.jsx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,44 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import './PeopleSelector.scss';
44

5+
import ReactDOMServer from 'react-dom/server';
56
import { twemojify } from '../../../util/twemojify';
67

78
import { blurOnBubbling } from '../../atoms/button/script';
89

910
import Text from '../../atoms/text/Text';
1011
import Avatar from '../../atoms/avatar/Avatar';
11-
import { getUserStatus, updateUserStatusIcon } from '../../../util/onlineStatus';
12+
import { getUserStatus, updateUserStatusIcon, getPresence } from '../../../util/onlineStatus';
1213

1314
function PeopleSelector({
1415
avatarSrc, name, color, peopleRole, onClick, user, disableStatus
1516
}) {
1617

1718
const statusRef = React.useRef(null);
1819
const customStatusRef = React.useRef(null);
20+
21+
const getCustomStatus = (content) => {
22+
23+
// Custom Status
24+
if (customStatusRef && customStatusRef.current) {
25+
26+
// Get Status
27+
const customStatus = customStatusRef.current;
28+
29+
if (content && content.presenceStatusMsg && typeof content.presenceStatusMsg.msg === 'string' && content.presenceStatusMsg.msg.length > 0) {
30+
customStatus.innerHTML = ReactDOMServer.renderToStaticMarkup(twemojify(content.presenceStatusMsg.msg.substring(0, 100), undefined, true, false, true));
31+
} else {
32+
customStatus.innerHTML = '';
33+
}
34+
35+
}
36+
37+
};
38+
39+
if (user) {
40+
getCustomStatus(getPresence(user));
41+
}
42+
1943
React.useEffect(() => {
2044
if (user) {
2145

@@ -27,7 +51,7 @@ function PeopleSelector({
2751
const status = statusRef.current;
2852

2953
// Update Status Icon
30-
updateUserStatusIcon(status, tinyUser);
54+
getCustomStatus(updateUserStatusIcon(status, tinyUser));
3155

3256
}
3357
};
@@ -58,7 +82,7 @@ function PeopleSelector({
5882

5983
<div className="small people-selector__name emoji-size-fix text-start">
6084
{twemojify(name)}
61-
<div ref={customStatusRef} className='very-small' />
85+
<div ref={customStatusRef} className='very-small text-gray text-truncate' />
6286
</div>
6387

6488
{peopleRole !== null && <Text className="people-selector__role" variant="b3">{peopleRole}</Text>}

0 commit comments

Comments
 (0)