Message List: Only group messages within less than 10 minutes

This commit is contained in:
Alexander Zinchuk 2021-06-30 00:22:47 +03:00
parent 7e0f69d197
commit 79550a47bd

View File

@ -6,6 +6,8 @@ import { isActionMessage } from '../../../modules/helpers';
type SenderGroup = (ApiMessage | IAlbum)[];
const GROUP_INTERVAL_SECONDS = 600; // 10 minutes
export type MessageDateGroup = {
originalDate: number;
datetime: number;
@ -55,11 +57,11 @@ export function groupMessages(messages: ApiMessage[], firstUnreadId?: number) {
currentAlbum = undefined;
}
if (nextMessage) {
const nextMessageDatetime = Number(getDayStart(nextMessage.date * 1000));
if (currentDateGroup.datetime !== nextMessageDatetime) {
const nextMessageDayStartsAt = Number(getDayStart(nextMessage.date * 1000));
if (currentDateGroup.datetime !== nextMessageDayStartsAt) {
currentDateGroup = {
originalDate: nextMessage.date,
datetime: nextMessageDatetime,
datetime: nextMessageDayStartsAt,
senderGroups: [],
};
dateGroups.push(currentDateGroup);
@ -82,6 +84,7 @@ export function groupMessages(messages: ApiMessage[], firstUnreadId?: number) {
)
|| message.inlineButtons
|| nextMessage.inlineButtons
|| (nextMessage.date - message.date) > GROUP_INTERVAL_SECONDS
) {
currentSenderGroup = [];
currentDateGroup.senderGroups.push(currentSenderGroup);