mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-06 15:35:52 -05:00
fix(messaging): only show date if date changes
This commit is contained in:
parent
3b6519c530
commit
f1a9c889b8
2 changed files with 12 additions and 8 deletions
|
@ -37,15 +37,15 @@ const Unread = styled.div`
|
|||
`;
|
||||
|
||||
interface Props {
|
||||
date: Date;
|
||||
date?: Date;
|
||||
unread?: boolean;
|
||||
}
|
||||
|
||||
export default function DateDivider(props: Props) {
|
||||
export default function DateDivider({ unread, date }: Props) {
|
||||
return (
|
||||
<Base unread={props.unread}>
|
||||
{props.unread && <Unread>NEW</Unread>}
|
||||
<time>{dayjs(props.date).format("LL")}</time>
|
||||
<Base unread={unread}>
|
||||
{unread && <Unread>NEW</Unread>}
|
||||
{date && <time>{dayjs(date).format("LL")}</time>}
|
||||
</Base>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ export default observer(({ last_id, renderer, highlight }: Props) => {
|
|||
prevAuthor: string,
|
||||
previousMasq: Nullable<Masquerade>,
|
||||
) {
|
||||
head = false;
|
||||
const atime = decodeTime(current),
|
||||
adate = new Date(atime),
|
||||
btime = decodeTime(previous),
|
||||
|
@ -115,14 +116,17 @@ export default observer(({ last_id, renderer, highlight }: Props) => {
|
|||
divided = true;
|
||||
}
|
||||
|
||||
head = false;
|
||||
let date;
|
||||
if (
|
||||
unread ||
|
||||
adate.getFullYear() !== bdate.getFullYear() ||
|
||||
adate.getMonth() !== bdate.getMonth() ||
|
||||
adate.getDate() !== bdate.getDate()
|
||||
) {
|
||||
render.push(<DateDivider date={adate} unread={unread} />);
|
||||
date = adate;
|
||||
}
|
||||
|
||||
if (unread || date) {
|
||||
render.push(<DateDivider date={date} unread={unread} />);
|
||||
head = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue