diff options
author | George Hazan <ghazan@miranda.im> | 2018-10-31 16:38:45 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-10-31 16:38:45 +0300 |
commit | 5cfe759310f1368eb5bcd3ed07918a61768f7cde (patch) | |
tree | 625ef2f3ab9ffe8848638c8cb1ed5a15a0602ab8 /protocols/Discord | |
parent | 5cc9245a01e968e8c6fbc801b46a489e7abbac15 (diff) |
Discord: subgroups usage is enabled for the new accounts only
Diffstat (limited to 'protocols/Discord')
-rw-r--r-- | protocols/Discord/src/guilds.cpp | 10 | ||||
-rw-r--r-- | protocols/Discord/src/proto.cpp | 16 | ||||
-rw-r--r-- | protocols/Discord/src/proto.h | 1 |
3 files changed, 22 insertions, 5 deletions
diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp index 7e1c2b83b7..402d82545e 100644 --- a/protocols/Discord/src/guilds.cpp +++ b/protocols/Discord/src/guilds.cpp @@ -164,6 +164,9 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS // filter our all channels but the text ones switch (pch["type"].as_int()) { case 4: // channel group + if (!m_bUseGuildGroups) // ignore groups when they aren't enabled + return nullptr; + pUser = FindUserByChannel(channelId); if (pUser == nullptr) { // missing channel - create it @@ -172,12 +175,11 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS pUser->channelId = channelId; pUser->bIsGroup = true; arUsers.insert(pUser); + pGuild->arChannels.insert(pUser); - if (m_bUseGuildGroups) { - MGROUP grpId = Clist_GroupCreate(pGuild->groupId, wszName); - pUser->wszChannelName = Clist_GroupGetName(grpId); - } + MGROUP grpId = Clist_GroupCreate(pGuild->groupId, wszName); + pUser->wszChannelName = Clist_GroupGetName(grpId); } return pUser; diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index 6e4164fd5b..a803488898 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -49,7 +49,7 @@ CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) : m_wszEmail(this, "Email", L""), m_wszDefaultGroup(this, "GroupName", DB_KEYVAL_GROUP), m_bHideGroupchats(this, "HideChats", true), - m_bUseGuildGroups(this, "UseGuildGroups", true) + m_bUseGuildGroups(this, "UseGuildGroups", false) { // Services CreateProtoService(PS_CREATEACCMGRUI, &CDiscordProto::SvcCreateAccMgrUI); @@ -62,6 +62,7 @@ CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) : // Events HookProtoEvent(ME_OPT_INITIALISE, &CDiscordProto::OnOptionsInit); HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CDiscordProto::OnDbEventRead); + HookProtoEvent(ME_PROTO_ACCLISTCHANGED, &CDiscordProto::OnAccountChanged); // database db_set_resident(m_szModuleName, "XStatusMsg"); @@ -457,6 +458,19 @@ int CDiscordProto::OnDbEventRead(WPARAM, LPARAM hDbEvent) ///////////////////////////////////////////////////////////////////////////////////////// +int CDiscordProto::OnAccountChanged(WPARAM iAction, LPARAM lParam) +{ + if (iAction == PRAC_ADDED) { + PROTOACCOUNT *pa = (PROTOACCOUNT*)lParam; + if (pa && pa->ppro == this) + m_bUseGuildGroups = true; + } + + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + void CDiscordProto::OnContactDeleted(MCONTACT hContact) { CDiscordUser *pUser = FindUser(getId(hContact, DB_KEY_ID)); diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index 60305b3630..6800fb52d6 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -321,6 +321,7 @@ public: // Events int __cdecl OnOptionsInit(WPARAM, LPARAM); + int __cdecl OnAccountChanged(WPARAM, LPARAM); int __cdecl OnDbEventRead(WPARAM, LPARAM); ////////////////////////////////////////////////////////////////////////////////////// |