diff options
author | George Hazan <george.hazan@gmail.com> | 2024-07-21 16:17:48 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-07-21 16:17:48 +0300 |
commit | 5fd260b7c4c98bfa2d17a301d832a859c2af1f92 (patch) | |
tree | 648dfe9336191c8fafdf7772f376f8e60337388a /protocols/Discord/src/proto.cpp | |
parent | 17b6a94812b2dbf4af29fb5d84064ceb1c7d393e (diff) |
fixes #4555 (Задваиваются контакты протоколов, где есть кэш)
Diffstat (limited to 'protocols/Discord/src/proto.cpp')
-rw-r--r-- | protocols/Discord/src/proto.cpp | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index 7cfeba6d56..7bf3dbcf0d 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -136,43 +136,6 @@ CDiscordProto::~CDiscordProto() void CDiscordProto::OnModulesLoaded()
{
- std::vector<MCONTACT> lostIds;
-
- // Fill users list
- for (auto &hContact : AccContacts()) {
- CDiscordUser *pNew = new CDiscordUser(getId(hContact, DB_KEY_ID));
- pNew->hContact = hContact;
- pNew->lastMsgId = getId(hContact, DB_KEY_LASTMSGID);
- pNew->wszUsername = ptrW(getWStringA(hContact, DB_KEY_NICK));
- pNew->iDiscriminator = getDword(hContact, DB_KEY_DISCR);
-
- // set EnableSync = 1 by default for all existing guilds
- switch (getByte(hContact, "ChatRoom")) {
- case 2: // guild
- delSetting(hContact, DB_KEY_CHANNELID);
- surelyGetBool(hContact, DB_KEY_ENABLE_HIST);
- surelyGetBool(hContact, DB_KEY_ENABLE_SYNC);
- break;
-
- case 1: // group chat
- pNew->channelId = getId(hContact, DB_KEY_CHANNELID);
- if (!pNew->channelId) {
- lostIds.push_back(hContact);
- delete pNew;
- continue;
- }
- break;
-
- default:
- pNew->channelId = getId(hContact, DB_KEY_CHANNELID);
- break;
- }
- arUsers.insert(pNew);
- }
-
- for (auto &hContact: lostIds)
- db_delete_contact(hContact);
-
// Clist
Clist_GroupCreate(0, m_wszDefaultGroup);
@@ -640,6 +603,48 @@ int CDiscordProto::OnAccountChanged(WPARAM iAction, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
+void CDiscordProto::OnCacheInit()
+{
+ std::vector<MCONTACT> lostIds;
+
+ // Fill users list
+ for (auto &hContact : AccContacts()) {
+ m_bCacheInited = true;
+
+ CDiscordUser *pNew = new CDiscordUser(getId(hContact, DB_KEY_ID));
+ pNew->hContact = hContact;
+ pNew->lastMsgId = getId(hContact, DB_KEY_LASTMSGID);
+ pNew->wszUsername = ptrW(getWStringA(hContact, DB_KEY_NICK));
+ pNew->iDiscriminator = getDword(hContact, DB_KEY_DISCR);
+
+ // set EnableSync = 1 by default for all existing guilds
+ switch (getByte(hContact, "ChatRoom")) {
+ case 2: // guild
+ delSetting(hContact, DB_KEY_CHANNELID);
+ surelyGetBool(hContact, DB_KEY_ENABLE_HIST);
+ surelyGetBool(hContact, DB_KEY_ENABLE_SYNC);
+ break;
+
+ case 1: // group chat
+ pNew->channelId = getId(hContact, DB_KEY_CHANNELID);
+ if (!pNew->channelId) {
+ lostIds.push_back(hContact);
+ delete pNew;
+ continue;
+ }
+ break;
+
+ default:
+ pNew->channelId = getId(hContact, DB_KEY_CHANNELID);
+ break;
+ }
+ arUsers.insert(pNew);
+ }
+
+ for (auto &hContact : lostIds)
+ db_delete_contact(hContact);
+}
+
bool CDiscordProto::OnContactDeleted(MCONTACT hContact, uint32_t flags)
{
if (flags & CDF_DEL_CONTACT) {
|