From ff7f56df48d8e43e5037db68b411e453214792c8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 5 Mar 2024 18:15:29 +0300 Subject: fixes #4262 (NewStory doesn't show user nicks in Telegram chat history) --- plugins/NewStory/src/history_array.cpp | 18 +++++++++++++----- plugins/NewStory/src/history_array.h | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 61209fa455..e82dade5aa 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -525,6 +525,8 @@ void HistoryArray::addChatEvent(SESSION_INFO *si, const LOGINFO *lin) if (si->pMI->bDatabase && lin->hEvent) { p.hEvent = lin->hEvent; p.load(); + if (p.dbe.szUserId) + addNick(p, Utf2T(p.dbe.szUserId)); } else { CMStringW wszText; @@ -565,11 +567,8 @@ void HistoryArray::addChatEvent(SESSION_INFO *si, const LOGINFO *lin) } if (lin->ptszNick) { - p.wszNick = strings.find(lin->ptszNick); - if (p.wszNick == nullptr) { - p.wszNick = mir_wstrdup(lin->ptszNick); - strings.insert(p.wszNick); - } + addNick(p, lin->ptszNick); + p.checkPrevGC((numItems == 0) ? nullptr : get(numItems - 1), hwndOwner); } } @@ -605,6 +604,15 @@ bool HistoryArray::addEvent(MCONTACT hContact, MEVENT hEvent, int count) return true; } +void HistoryArray::addNick(ItemData &pItem, wchar_t *pwszNick) +{ + pItem.wszNick = strings.find(pwszNick); + if (pItem.wszNick == nullptr) { + pItem.wszNick = mir_wstrdup(pwszNick); + strings.insert(pItem.wszNick); + } +} + void HistoryArray::addResults(const OBJLIST &pArray) { int numItems = getCount(); diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index df0142308f..04c7be3cd4 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -140,6 +140,8 @@ public: bool addEvent(MCONTACT hContact, MEVENT hEvent, int count); void addChatEvent(SESSION_INFO *si, const LOGINFO *pEvent); void addResults(const OBJLIST &pArray); + + void addNick(ItemData &pItem, wchar_t *pwszNick); void clear(); int find(MEVENT hEvent); int find(int id, int dir, const Filter &filter); -- cgit v1.2.3