2019-06-05 01:46:36 +03:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import classnames from 'classnames';
|
2019-06-20 03:05:18 +03:00
|
|
|
import _ from 'lodash';
|
2019-06-05 01:46:36 +03:00
|
|
|
|
|
|
|
|
|
|
|
export default class ChatTile extends Component {
|
|
|
|
|
2019-06-08 02:46:46 +03:00
|
|
|
render() {
|
2019-07-12 02:26:33 +03:00
|
|
|
const { props } = this;
|
2019-06-20 03:05:18 +03:00
|
|
|
|
2019-10-01 02:28:15 +03:00
|
|
|
let data = _.get(props.data, 'chat-configs', false);
|
2019-07-12 02:26:33 +03:00
|
|
|
|
2019-10-01 02:28:15 +03:00
|
|
|
let inviteNum = 0;
|
|
|
|
let msgNum = 0;
|
2019-06-24 23:29:56 +03:00
|
|
|
|
2019-10-01 02:28:15 +03:00
|
|
|
if (data) {
|
|
|
|
Object.keys(data).forEach((conf) => {
|
|
|
|
console.log(conf);
|
|
|
|
msgNum = msgNum + data[conf].length - data[conf].read;
|
|
|
|
});
|
2019-06-22 02:09:04 +03:00
|
|
|
}
|
|
|
|
|
2020-02-06 02:16:56 +03:00
|
|
|
let notificationsNum = inviteNum + msgNum;
|
|
|
|
|
|
|
|
let numNotificationsElem =
|
|
|
|
notificationsNum > 0 ? (
|
|
|
|
<p
|
2020-02-22 05:57:27 +03:00
|
|
|
className="absolute green2 white-d"
|
2020-02-06 02:16:56 +03:00
|
|
|
style={{
|
|
|
|
bottom: 6,
|
|
|
|
fontWeight: 400,
|
|
|
|
fontSize: 12,
|
|
|
|
lineHeight: "20px"
|
|
|
|
}}>
|
|
|
|
{notificationsNum > 99 ? "99+" : notificationsNum}
|
|
|
|
</p>
|
|
|
|
) : (
|
|
|
|
<div />
|
|
|
|
);
|
2019-07-12 21:05:26 +03:00
|
|
|
|
2019-06-05 01:46:36 +03:00
|
|
|
return (
|
2020-02-22 05:57:27 +03:00
|
|
|
<div className={"w-100 h-100 relative bg-white bg-gray0-d ba " +
|
|
|
|
"b--black b--gray1-d"}>
|
2019-06-20 03:05:18 +03:00
|
|
|
<a className="w-100 h-100 db pa2 no-underline" href="/~chat">
|
2020-02-22 05:57:27 +03:00
|
|
|
<p className="black white-d absolute f9" style={{left: 8, top: 8}}>Messaging</p>
|
2019-06-20 03:05:18 +03:00
|
|
|
<img
|
2020-02-22 05:57:27 +03:00
|
|
|
className="absolute invert-d"
|
2020-02-06 02:16:56 +03:00
|
|
|
style={{ left: 39, top: 39 }}
|
2019-06-20 03:05:18 +03:00
|
|
|
src="/~chat/img/Tile.png"
|
2020-02-06 02:16:56 +03:00
|
|
|
width={48}
|
|
|
|
height={48} />
|
|
|
|
{numNotificationsElem}
|
2019-06-08 02:46:46 +03:00
|
|
|
</a>
|
2019-06-05 01:46:36 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-10-01 02:28:15 +03:00
|
|
|
window['chat-viewTile'] = ChatTile;
|