#368 Sort past chats by the last message

This commit is contained in:
SillyLossy
2023-05-23 12:23:56 +03:00
parent 6ea0b04472
commit 588e797317
5 changed files with 39 additions and 4 deletions

View File

@@ -1206,9 +1206,11 @@ export async function getGroupPastChats(groupId) {
let this_chat_file_size = (JSON.stringify(messages).length / 1024).toFixed(2) + "kb";
let chat_items = messages.length;
const lastMessage = messages.length ? messages[messages.length - 1].mes : '[The chat is empty]';
const lastMessageDate = messages.length ? (messages[messages.length - 1].send_date || Date.now()) : Date.now();
chats.push({
'file_name': chatId,
'mes': lastMessage,
'last_mes': lastMessageDate,
'file_size': this_chat_file_size,
'chat_items': chat_items,
});
@@ -1303,7 +1305,7 @@ export async function importGroupChat(formData) {
if (data.res) {
const chatId = data.res;
const group = groups.find(x => x.id == selected_group);
if (group) {
group.chats.push(chatId);
await editGroup(selected_group, true, true);
@@ -1369,4 +1371,4 @@ jQuery(() => {
const value = $(this).prop("checked");
is_group_automode_enabled = value;
});
});
});