Merge pull request #3122 from urbit/lf/chat-unreads-jank

chat-js: unread counts sweep
This commit is contained in:
matildepark 2020-07-13 23:26:43 -04:00 committed by GitHub
commit 8dd482ca40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -73,6 +73,7 @@ export default class ChatApp extends React.Component<ChatAppProps, {}> {
unreads[stat] = Boolean(unread); unreads[stat] = Boolean(unread);
if ( if (
unread && unread &&
stat in associations.chat &&
(selectedGroups.length === 0 || (selectedGroups.length === 0 ||
selectedGroups selectedGroups
.map((e) => { .map((e) => {

View File

@ -1,4 +1,4 @@
import React, { Component } from "react"; import React, { Component, Fragment } from "react";
import _ from "lodash"; import _ from "lodash";
import moment from "moment"; import moment from "moment";
@ -359,6 +359,10 @@ export class ChatScreen extends Component<ChatScreenProps, ChatScreenState> {
props.pendingMessages.get(props.station) || [] props.pendingMessages.get(props.station) || []
).map((value) => ({ ...value, pending: true })); ).map((value) => ({ ...value, pending: true }));
if(unread !== 0) {
unread += pendingMessages.length;
}
messages = pendingMessages.concat(messages); messages = pendingMessages.concat(messages);
const messageElements = messages.map((msg, i) => { const messageElements = messages.map((msg, i) => {
@ -389,10 +393,9 @@ export class ChatScreen extends Component<ChatScreenProps, ChatScreenState> {
); );
if (unread > 0 && i === unread - 1) { if (unread > 0 && i === unread - 1) {
return ( return (
<> <Fragment key={msg.uid}>
{messageElem} {messageElem}
<div <div
key={"unreads" + msg.uid}
ref={this.setUnreadMarker} ref={this.setUnreadMarker}
className="mv2 green2 flex items-center f9" className="mv2 green2 flex items-center f9"
> >
@ -409,19 +412,18 @@ export class ChatScreen extends Component<ChatScreenProps, ChatScreenState> {
className="b--green2 ma0 bt-0" className="b--green2 ma0 bt-0"
/> />
</div> </div>
</> </Fragment>
); );
} else if (dayBreak) { } else if (dayBreak) {
return ( return (
<> <Fragment key={msg.uid}>
{messageElem} {messageElem}
<div <div
key={"daybreak" + msg.uid}
className="pv3 gray2 b--gray2 flex items-center justify-center f9 " className="pv3 gray2 b--gray2 flex items-center justify-center f9 "
> >
<p>{moment(_.get(messages[i], when)).calendar()}</p> <p>{moment(_.get(messages[i], when)).calendar()}</p>
</div> </div>
</> </Fragment>
); );
} else { } else {
return messageElem; return messageElem;