summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-07-21 16:17:48 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-07-21 16:17:48 +0300
commit5fd260b7c4c98bfa2d17a301d832a859c2af1f92 (patch)
tree648dfe9336191c8fafdf7772f376f8e60337388a /protocols/Telegram/src
parent17b6a94812b2dbf4af29fb5d84064ceb1c7d393e (diff)
fixes #4555 (Задваиваются контакты протоколов, где есть кэш)
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r--protocols/Telegram/src/proto.cpp35
-rw-r--r--protocols/Telegram/src/proto.h1
2 files changed, 21 insertions, 15 deletions
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index f321758700..05690aa8c0 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -109,6 +109,26 @@ CTelegramProto::~CTelegramProto()
{
}
+void CTelegramProto::OnCacheInit()
+{
+ int iCompatLevel = getByte(DBKEY_COMPAT);
+ VARSW cachePath(L"%miranda_userdata%\\ChatCache");
+
+ for (auto &cc : AccContacts()) {
+ m_bCacheInited = true;
+
+ if (int64_t id = GetId(cc)) {
+ bool isGroupChat = isChatRoom(cc);
+ auto *pUser = new TG_USER(id, cc, isGroupChat);
+ pUser->szAvatarHash = getMStringA(cc, DBKEY_AVATAR_HASH);
+ m_arUsers.insert(pUser);
+ if (isGroupChat && iCompatLevel < 3)
+ _wremove(CMStringW(FORMAT, L"%s\\%d.json", cachePath.get(), cc));
+ }
+ }
+ setByte(DBKEY_COMPAT, 3);
+}
+
void CTelegramProto::OnContactAdded(MCONTACT hContact)
{
if (int64_t id = GetId(hContact)) {
@@ -146,21 +166,6 @@ bool CTelegramProto::OnContactDeleted(MCONTACT hContact, uint32_t flags)
void CTelegramProto::OnModulesLoaded()
{
- int iCompatLevel = getByte(DBKEY_COMPAT);
- VARSW cachePath(L"%miranda_userdata%\\ChatCache");
-
- for (auto &cc : AccContacts()) {
- if (int64_t id = GetId(cc)) {
- bool isGroupChat = isChatRoom(cc);
- auto *pUser = new TG_USER(id, cc, isGroupChat);
- pUser->szAvatarHash = getMStringA(cc, DBKEY_AVATAR_HASH);
- m_arUsers.insert(pUser);
- if (isGroupChat && iCompatLevel < 3)
- _wremove(CMStringW(FORMAT, L"%s\\%d.json", cachePath.get(), cc));
- }
- }
- setByte(DBKEY_COMPAT, 3);
-
m_bSmileyAdd = ServiceExists(MS_SMILEYADD_REPLACESMILEYS);
if (m_bSmileyAdd)
SmileyAdd_LoadContactSmileys(SMADD_FOLDER, m_szModuleName, GetAvatarPath() + L"\\Stickers\\*.*");
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 2216a3dc2b..988c2071b8 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -394,6 +394,7 @@ public:
int UserIsTyping(MCONTACT hContact, int type) override;
void OnBuildProtoMenu() override;
+ void OnCacheInit() override;
void OnContactAdded(MCONTACT hContact) override;
bool OnContactDeleted(MCONTACT hContact, uint32_t flags) override;
MWindow OnCreateAccMgrUI(MWindow hwndParent) override;