SHA256
UI: render DM inbox from dialogs
This commit is contained in:
@@ -509,6 +509,22 @@ function parseSignedMessageBlockBytes(bytes) {
|
||||
};
|
||||
}
|
||||
|
||||
function extractContactsFromDialogs(dialogs) {
|
||||
const seen = new Set();
|
||||
const out = [];
|
||||
(Array.isArray(dialogs) ? dialogs : []).forEach((dialog) => {
|
||||
const relationFlag = String(dialog?.relationFlag || '').trim().toLowerCase();
|
||||
if (relationFlag !== 'contact' && relationFlag !== 'close_friend') return;
|
||||
const login = String(dialog?.peerLogin || '').trim();
|
||||
if (!login) return;
|
||||
const key = login.toLowerCase();
|
||||
if (seen.has(key)) return;
|
||||
seen.add(key);
|
||||
out.push(login);
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
function makeUserParamBodyBytes({ lineCode, prevLineNumber, prevLineHashHex, thisLineNumber, key, value }) {
|
||||
const keyBytes = utf8Bytes(String(key || ''));
|
||||
const valueBytes = utf8Bytes(String(value || ''));
|
||||
@@ -2852,7 +2868,11 @@ export class AuthService {
|
||||
async listContacts() {
|
||||
const response = await this.ws.request('ListContacts', {});
|
||||
if (response.status !== 200) throw opError('ListContacts', response);
|
||||
return response.payload || {};
|
||||
const payload = response.payload || {};
|
||||
if (Array.isArray(payload.dialogs) && !Array.isArray(payload.contacts)) {
|
||||
payload.contacts = extractContactsFromDialogs(payload.dialogs);
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user