From c9b3309c86a2f8914f0496292ba3ebe4cbca877e Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Mon, 10 Feb 2020 23:08:10 +0700 Subject: [PATCH] dialog avatar colors --- .DS_Store | Bin 10244 -> 10244 bytes src/lib/appManagers/appDialogsManager.ts | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/.DS_Store b/.DS_Store index 9dd56de43c2e1cab938baee7b39a86f5e45eb0b8..8ce924c1067e2d087115d4f83ce177a36c319531 100644 GIT binary patch delta 372 zcmZn(XbG6$jIU^hRb_GTV|4eZWp3`Gp732ES4sW= delta 42 ycmZn(XbG6$mJU^hRb`eq)14eXomN%S&qo-dWby0IaQaWlKZR`$vFBs>5_*AFNF diff --git a/src/lib/appManagers/appDialogsManager.ts b/src/lib/appManagers/appDialogsManager.ts index f94f5a5a..69e5904b 100644 --- a/src/lib/appManagers/appDialogsManager.ts +++ b/src/lib/appManagers/appDialogsManager.ts @@ -20,6 +20,9 @@ type DialogDom = { listEl: HTMLLIElement }; +const DialogColors = ['#c03d33', '#4fad2d', '#d09306', '#168acd', '#8544d6', '#cd4073', '#2996ad', '#ce671b']; +const DialogColorsMap = [0, 7, 4, 1, 6, 3, 5]; + export class AppDialogsManager { public chatList = document.getElementById('dialogs') as HTMLUListElement; public pinnedDelimiter: HTMLDivElement; @@ -73,6 +76,17 @@ export class AppDialogsManager { }); } + /* + HTML-color IRC-color Description + #c03d33 4 red + #4fad2d 3 green + #d09306 7 yellow + #168acd 10 blue + #8544d6 6 purple + #cd4073 13 pink + #2996ad 11 sea + #ce671b 5 orange + */ public async loadDialogPhoto(div: HTMLDivElement, peerID: number | string, isDialog = false): Promise { let inputPeer: any; let location: any; @@ -98,8 +112,14 @@ export class AppDialogsManager { div.firstChild.remove(); } + let color = ''; + if(typeof(peerID) != 'string') { + color = DialogColors[DialogColorsMap[(peerID < 0 ? -peerID : peerID) % 7]]; + } + div.classList.remove('tgico-savedmessages'); div.style.fontSize = ''; + div.style.backgroundColor = color; let abbrSplitted = (typeof(peerID) != 'string' ? appPeersManager.getPeerTitle(peerID, true) : peerID).split(' '); let abbr = (abbrSplitted.length == 2 ?