From 9f40e8aa80525dcf0343ffa82cb137a6f3d8b258 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 8 Jun 2019 14:02:35 +0300 Subject: Discord: fix for problems of small Guilds (missing nick list, duplicate group chat messages) --- protocols/Discord/src/guilds.cpp | 24 ++++++++++++++++++++---- protocols/Discord/src/proto.h | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'protocols') 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 . #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; -- cgit v1.2.3