From 06c58764af8c22450d70d1819d9a35fdf12605b4 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 14 Jul 2020 10:36:22 +1000 Subject: [PATCH 1/2] chat-js: fix unread key issues in ChatScreen --- pkg/interface/src/apps/chat/components/chat.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/interface/src/apps/chat/components/chat.tsx b/pkg/interface/src/apps/chat/components/chat.tsx index cd943f2ef6..69ddb02bd0 100644 --- a/pkg/interface/src/apps/chat/components/chat.tsx +++ b/pkg/interface/src/apps/chat/components/chat.tsx @@ -1,4 +1,4 @@ -import React, { Component } from "react"; +import React, { Component, Fragment } from "react"; import _ from "lodash"; import moment from "moment"; @@ -359,6 +359,10 @@ export class ChatScreen extends Component { props.pendingMessages.get(props.station) || [] ).map((value) => ({ ...value, pending: true })); + if(unread !== 0) { + unread += pendingMessages.length; + } + messages = pendingMessages.concat(messages); const messageElements = messages.map((msg, i) => { @@ -389,10 +393,9 @@ export class ChatScreen extends Component { ); if (unread > 0 && i === unread - 1) { return ( - <> + {messageElem}
@@ -409,19 +412,18 @@ export class ChatScreen extends Component { className="b--green2 ma0 bt-0" />
- +
); } else if (dayBreak) { return ( - <> + {messageElem}

{moment(_.get(messages[i], when)).calendar()}

- +
); } else { return messageElem; From 73983068583ec126dafe5363ffc82e4814110453 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 14 Jul 2020 11:41:48 +1000 Subject: [PATCH 2/2] chat-js: check for association in unreads count Ensure chat has association so that we don't show chats from groups that we are no longer in. Fixes #2818 --- pkg/interface/src/apps/chat/app.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/interface/src/apps/chat/app.tsx b/pkg/interface/src/apps/chat/app.tsx index 4851dc7181..86831249dc 100644 --- a/pkg/interface/src/apps/chat/app.tsx +++ b/pkg/interface/src/apps/chat/app.tsx @@ -73,6 +73,7 @@ export default class ChatApp extends React.Component { unreads[stat] = Boolean(unread); if ( unread && + stat in associations.chat && (selectedGroups.length === 0 || selectedGroups .map((e) => {