mirror of
https://github.com/urbit/shrub.git
synced 2024-12-24 20:47:27 +03:00
Merge pull request #3122 from urbit/lf/chat-unreads-jank
chat-js: unread counts sweep
This commit is contained in:
commit
8dd482ca40
@ -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) => {
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user