mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-03 18:17:59 +01:00
Message List: Only group messages within less than 10 minutes
This commit is contained in:
parent
7e0f69d197
commit
79550a47bd
@ -6,6 +6,8 @@ import { isActionMessage } from '../../../modules/helpers';
|
|||||||
|
|
||||||
type SenderGroup = (ApiMessage | IAlbum)[];
|
type SenderGroup = (ApiMessage | IAlbum)[];
|
||||||
|
|
||||||
|
const GROUP_INTERVAL_SECONDS = 600; // 10 minutes
|
||||||
|
|
||||||
export type MessageDateGroup = {
|
export type MessageDateGroup = {
|
||||||
originalDate: number;
|
originalDate: number;
|
||||||
datetime: number;
|
datetime: number;
|
||||||
@ -55,11 +57,11 @@ export function groupMessages(messages: ApiMessage[], firstUnreadId?: number) {
|
|||||||
currentAlbum = undefined;
|
currentAlbum = undefined;
|
||||||
}
|
}
|
||||||
if (nextMessage) {
|
if (nextMessage) {
|
||||||
const nextMessageDatetime = Number(getDayStart(nextMessage.date * 1000));
|
const nextMessageDayStartsAt = Number(getDayStart(nextMessage.date * 1000));
|
||||||
if (currentDateGroup.datetime !== nextMessageDatetime) {
|
if (currentDateGroup.datetime !== nextMessageDayStartsAt) {
|
||||||
currentDateGroup = {
|
currentDateGroup = {
|
||||||
originalDate: nextMessage.date,
|
originalDate: nextMessage.date,
|
||||||
datetime: nextMessageDatetime,
|
datetime: nextMessageDayStartsAt,
|
||||||
senderGroups: [],
|
senderGroups: [],
|
||||||
};
|
};
|
||||||
dateGroups.push(currentDateGroup);
|
dateGroups.push(currentDateGroup);
|
||||||
@ -82,6 +84,7 @@ export function groupMessages(messages: ApiMessage[], firstUnreadId?: number) {
|
|||||||
)
|
)
|
||||||
|| message.inlineButtons
|
|| message.inlineButtons
|
||||||
|| nextMessage.inlineButtons
|
|| nextMessage.inlineButtons
|
||||||
|
|| (nextMessage.date - message.date) > GROUP_INTERVAL_SECONDS
|
||||||
) {
|
) {
|
||||||
currentSenderGroup = [];
|
currentSenderGroup = [];
|
||||||
currentDateGroup.senderGroups.push(currentSenderGroup);
|
currentDateGroup.senderGroups.push(currentSenderGroup);
|
||||||
|
Loading…
Reference in New Issue
Block a user