diff --git a/app/soapbox/features/chats/components/chat_list.js b/app/soapbox/features/chats/components/chat_list.js index 7cd03401d..a1fbbcc57 100644 --- a/app/soapbox/features/chats/components/chat_list.js +++ b/app/soapbox/features/chats/components/chat_list.js @@ -20,8 +20,14 @@ const chatDateComparator = (chatA, chatB) => { const mapStateToProps = state => { const getChat = makeGetChat(); + + const chats = state.get('chats') + .map(chat => getChat(state, chat.toJS())) + .toList() + .sort(chatDateComparator); + return { - chats: state.get('chats').map(chat => getChat(state, chat.toJS())).toList().sort(chatDateComparator), + chats, }; }; diff --git a/app/soapbox/features/chats/components/chat_list_account.js b/app/soapbox/features/chats/components/chat_list_account.js index 48a813fa8..531587784 100644 --- a/app/soapbox/features/chats/components/chat_list_account.js +++ b/app/soapbox/features/chats/components/chat_list_account.js @@ -4,6 +4,7 @@ import PropTypes from 'prop-types'; import Avatar from '../../../components/avatar'; import DisplayName from '../../../components/display_name'; import ImmutablePureComponent from 'react-immutable-pure-component'; +import { shortNumberFormat } from 'soapbox/utils/numbers'; export default class ChatListAccount extends ImmutablePureComponent { @@ -20,6 +21,7 @@ export default class ChatListAccount extends ImmutablePureComponent { const { chat } = this.props; if (!chat) return null; const account = chat.get('account'); + const unreadCount = chat.get('unread'); return (
@@ -30,6 +32,7 @@ export default class ChatListAccount extends ImmutablePureComponent {
+ {unreadCount > 0 && {shortNumberFormat(unreadCount)}} diff --git a/app/soapbox/features/chats/components/chat_panes.js b/app/soapbox/features/chats/components/chat_panes.js index e3a7db113..321c0796d 100644 --- a/app/soapbox/features/chats/components/chat_panes.js +++ b/app/soapbox/features/chats/components/chat_panes.js @@ -10,6 +10,7 @@ import { FormattedMessage } from 'react-intl'; import { makeGetChat } from 'soapbox/selectors'; import { openChat, toggleMainWindow } from 'soapbox/actions/chats'; import ChatWindow from './chat_window'; +import { shortNumberFormat } from 'soapbox/utils/numbers'; const addChatsToPanes = (state, panesData) => { const getChat = makeGetChat(); @@ -27,6 +28,7 @@ const mapStateToProps = state => { return { panesData: addChatsToPanes(state, panesData), + unreadCount: state.get('chats').reduce((acc, curr) => acc + curr.get('unread'), 0), }; }; @@ -50,7 +52,7 @@ class ChatPanes extends ImmutablePureComponent { } render() { - const { panesData } = this.props; + const { panesData, unreadCount } = this.props; const panes = panesData.get('panes'); const mainWindow = panesData.get('mainWindow'); @@ -60,6 +62,7 @@ class ChatPanes extends ImmutablePureComponent { + {unreadCount > 0 && {shortNumberFormat(unreadCount)}}
({ me: state.get('me'), + chat: state.getIn(['chats', pane.get('chat_id')]), chatMessageIds: state.getIn(['chat_message_lists', pane.get('chat_id')], ImmutableOrderedSet()), }); @@ -26,6 +28,7 @@ class ChatWindow extends ImmutablePureComponent { pane: ImmutablePropTypes.map.isRequired, idx: PropTypes.number, chatMessageIds: ImmutablePropTypes.orderedSet, + chat: ImmutablePropTypes.map, me: PropTypes.node, } @@ -88,12 +91,12 @@ class ChatWindow extends ImmutablePureComponent { } render() { - const { pane, idx, chatMessageIds } = this.props; - const chat = pane.get('chat'); + const { pane, idx, chatMessageIds, chat } = this.props; const account = pane.getIn(['chat', 'account']); if (!chat || !account) return null; const right = (285 * (idx + 1)) + 20; + const unreadCount = chat.get('unread'); return (
@@ -102,6 +105,7 @@ class ChatWindow extends ImmutablePureComponent { + {unreadCount > 0 && {shortNumberFormat(unreadCount)}}
diff --git a/app/styles/chats.scss b/app/styles/chats.scss index c73542db3..410769b8d 100644 --- a/app/styles/chats.scss +++ b/app/styles/chats.scss @@ -67,6 +67,11 @@ .pane__close { margin-left: auto; } + + .icon-with-badge__badge { + position: static; + pointer-events: none; + } } &__content { @@ -142,4 +147,15 @@ background: transparent; align-items: start; } + + .account__display-name { + position: relative; + } + + .icon-with-badge__badge { + top: 0; + right: 0; + left: auto; + bottom: auto; + } }