diff options
author | George Hazan <ghazan@miranda.im> | 2019-06-08 14:02:35 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-06-08 14:02:35 +0300 |
commit | 9f40e8aa80525dcf0343ffa82cb137a6f3d8b258 (patch) | |
tree | b03ee9e659fe854bbb7e5d0f1c6aafad70a9881d /protocols | |
parent | a72c1249cee354f27967b266028a68bf0990eee4 (diff) |
Discord: fix for problems of small Guilds (missing nick list, duplicate group chat messages)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Discord/src/guilds.cpp | 24 | ||||
-rw-r--r-- | protocols/Discord/src/proto.h | 1 |
2 files changed, 21 insertions, 4 deletions
diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp index 633303cf59..7b48b87e90 100644 --- a/protocols/Discord/src/guilds.cpp +++ b/protocols/Discord/src/guilds.cpp @@ -17,6 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h" +class CChatRoomDlg : public CSrmmBaseDialog +{ + CChatRoomDlg(); // just to suppress compiler's warnings, never implemented +}; + int compareUsers(const CDiscordUser *p1, const CDiscordUser *p2); static int compareRoles(const CDiscordRole *p1, const CDiscordRole *p2) @@ -218,8 +223,10 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS SnowFlake oldMsgId = getId(pUser->hContact, DB_KEY_LASTMSGID); if (oldMsgId == 0) RetrieveHistory(pUser, MSG_BEFORE, pUser->lastMsgId, 20); - else if (pUser->lastMsgId > oldMsgId) + else if (!pUser->bSynced && pUser->lastMsgId > oldMsgId) { + pUser->bSynced = true; RetrieveHistory(pUser, MSG_AFTER, oldMsgId, 99); + } setId(pUser->hContact, DB_KEY_ID, channelId); setId(pUser->hContact, DB_KEY_CHANNELID, channelId); @@ -307,9 +314,18 @@ void CDiscordProto::ParseGuildContents(CDiscordGuild *pGuild, const JSONNode &pR if (it->bIsPrivate) continue; - SnowFlake oldMsgId = getId(it->hContact, DB_KEY_LASTMSGID); - if (oldMsgId != 0 && it->lastMsgId > oldMsgId) - RetrieveHistory(it, MSG_AFTER, oldMsgId, 99); + if (newMembers.getCount()) { + auto *si = g_chatApi.SM_FindSession(it->wszUsername, m_szModuleName); + if (si && si->pDlg) + si->pDlg->UpdateNickList(); + } + + if (!it->bSynced) { + it->bSynced = true; + SnowFlake oldMsgId = getId(it->hContact, DB_KEY_LASTMSGID); + if (oldMsgId != 0 && it->lastMsgId > oldMsgId) + RetrieveHistory(it, MSG_AFTER, oldMsgId, 99); + } } pGuild->bSynced = true; diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index 3b3d83fda2..3e4b0065dc 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -65,6 +65,7 @@ struct CDiscordUser : public MZeroedObject SnowFlake parentId; bool bIsPrivate; bool bIsGroup; + bool bSynced; struct CDiscordGuild *pGuild; |