-
Notifications
You must be signed in to change notification settings - Fork 630
/
Copy pathArchive.js
29 lines (26 loc) · 1.04 KB
/
Archive.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* Copyright (c) 2018-present, Evgeny Nadymov
*
* This source code is licensed under the GPL v.3.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { orderCompare } from './Common';
import { getChatOrder } from './Chat';
import ChatStore from '../Stores/ChatStore';
export function getArchiveTitle() {
const archive = ChatStore.chatList.get('chatListArchive');
const chats = [];
const chatsOrder = [];
if (archive) {
for (const chatId of archive.keys()) {
const chat = ChatStore.get(chatId);
if (chat) {
const order = getChatOrder(chatId, { '@type': 'chatListArchive' });
if (order !== '0') chats.push(chat);
chatsOrder.push({ order, id: chatId, title: chat.title });
}
}
}
const orderedChats = chats.sort((a, b) => orderCompare(getChatOrder(b, { '@type': 'chatListArchive' }), getChatOrder(a, { '@type': 'chatListArchive' })));
return orderedChats.map(x => x.title).join(', ');
}