mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-26 15:32:11 -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 {
|
interface Props {
|
||||||
date: Date;
|
date?: Date;
|
||||||
unread?: boolean;
|
unread?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function DateDivider(props: Props) {
|
export default function DateDivider({ unread, date }: Props) {
|
||||||
return (
|
return (
|
||||||
<Base unread={props.unread}>
|
<Base unread={unread}>
|
||||||
{props.unread && <Unread>NEW</Unread>}
|
{unread && <Unread>NEW</Unread>}
|
||||||
<time>{dayjs(props.date).format("LL")}</time>
|
{date && <time>{dayjs(date).format("LL")}</time>}
|
||||||
</Base>
|
</Base>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ export default observer(({ last_id, renderer, highlight }: Props) => {
|
||||||
prevAuthor: string,
|
prevAuthor: string,
|
||||||
previousMasq: Nullable<Masquerade>,
|
previousMasq: Nullable<Masquerade>,
|
||||||
) {
|
) {
|
||||||
|
head = false;
|
||||||
const atime = decodeTime(current),
|
const atime = decodeTime(current),
|
||||||
adate = new Date(atime),
|
adate = new Date(atime),
|
||||||
btime = decodeTime(previous),
|
btime = decodeTime(previous),
|
||||||
|
@ -115,14 +116,17 @@ export default observer(({ last_id, renderer, highlight }: Props) => {
|
||||||
divided = true;
|
divided = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
head = false;
|
let date;
|
||||||
if (
|
if (
|
||||||
unread ||
|
|
||||||
adate.getFullYear() !== bdate.getFullYear() ||
|
adate.getFullYear() !== bdate.getFullYear() ||
|
||||||
adate.getMonth() !== bdate.getMonth() ||
|
adate.getMonth() !== bdate.getMonth() ||
|
||||||
adate.getDate() !== bdate.getDate()
|
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;
|
head = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue