From 7d053a2f4a6c6b8ba7400fce490bab6418672191 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 15 Nov 2022 14:16:51 +0300 Subject: let's assign a group name only if it's missing, don't touch manually assigned group names --- src/mir_app/src/chat_clist.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index f9c1eb4597..7358635617 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -24,22 +24,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *pszDisplayName, int iType) { - ptrW wszGroup(Chat_GetGroup()); - if (mir_wstrlen(wszGroup)) { - MGROUP hGroup = Clist_GroupExists(wszGroup); + ptrW pwszGroup(Chat_GetGroup()); + if (mir_wstrlen(pwszGroup)) { + MGROUP hGroup = Clist_GroupExists(pwszGroup); if (hGroup == 0) { - hGroup = Clist_GroupCreate(0, wszGroup); + hGroup = Clist_GroupCreate(0, pwszGroup); if (hGroup) Clist_GroupSetExpanded(hGroup, 1); } } MCONTACT hContact = g_chatApi.FindRoom(pszModule, pszRoom); - if (hContact) { // contact exist, make sure it is in the right group - if (mir_wstrlen(wszGroup)) { - ptrW grpName(Clist_GetGroup(hContact)); - if (mir_wstrcmp(wszGroup, grpName)) - Clist_SetGroup(hContact, wszGroup); + if (hContact) { + // contact exists, let's assign the standard group name if it's missing + if (mir_wstrlen(pwszGroup)) { + ptrW pwszOldGroup(Clist_GetGroup(hContact)); + if (!mir_wstrlen(pwszOldGroup)) + Clist_SetGroup(hContact, pwszGroup); } db_set_w(hContact, pszModule, "Status", ID_STATUS_OFFLINE); @@ -52,7 +53,7 @@ MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *p return 0; Proto_AddToContact(hContact, pszModule); - Clist_SetGroup(hContact, wszGroup); + Clist_SetGroup(hContact, pwszGroup); db_set_ws(hContact, pszModule, "Nick", pszDisplayName); db_set_ws(hContact, pszModule, "ChatRoomID", pszRoom); -- cgit v1.2.3