summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-03-06 12:51:38 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-03-06 12:51:38 +0300
commit9e87a0d2f319f87d7edf65db8baba9dae1b8862b (patch)
treee489237f7f56e31363a687abb11133a463bde4ec /plugins
parentabcf85f5475d62c7df49746c9d6d3f1b8ecae163 (diff)
fixes #4262 (NewStory: no nicks in Telegram chat history)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NewStory/src/history_array.cpp32
-rw-r--r--plugins/NewStory/src/history_array.h1
2 files changed, 28 insertions, 5 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp
index 195cf55896..81a2477619 100644
--- a/plugins/NewStory/src/history_array.cpp
+++ b/plugins/NewStory/src/history_array.cpp
@@ -521,9 +521,7 @@ 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));
+ checkGC(p, si);
}
else {
CMStringW wszText;
@@ -577,12 +575,20 @@ bool HistoryArray::addEvent(MCONTACT hContact, MEVENT hEvent, int count)
int numItems = getCount();
auto *pPrev = (numItems == 0) ? nullptr : get(numItems - 1);
+
+ SESSION_INFO *si = nullptr;
+ if (Contact::IsGroupChat(hContact))
+ si = Chat_Find(hContact);
if (count == 1) {
auto &p = allocateItem();
p.hContact = hContact;
p.hEvent = hEvent;
- pPrev = p.checkPrev(pPrev, hwndOwner);
+ if (si) {
+ checkGC(p, si);
+ pPrev = p.checkPrevGC(pPrev, hwndOwner);
+ }
+ else pPrev = p.checkPrev(pPrev, hwndOwner);
}
else {
DB::ECPTR pCursor(DB::Events(hContact, hEvent));
@@ -594,7 +600,11 @@ bool HistoryArray::addEvent(MCONTACT hContact, MEVENT hEvent, int count)
auto &p = allocateItem();
p.hContact = hContact;
p.hEvent = hEvent;
- pPrev = p.checkPrev(pPrev, hwndOwner);
+ if (si) {
+ checkGC(p, si);
+ pPrev = p.checkPrevGC(pPrev, hwndOwner);
+ }
+ else pPrev = p.checkPrev(pPrev, hwndOwner);
}
}
@@ -637,6 +647,18 @@ ItemData& HistoryArray::allocateItem()
return p.data[iLastPageCounter++];
}
+void HistoryArray::checkGC(ItemData &p, SESSION_INFO *si)
+{
+ p.load();
+ if (p.dbe.szUserId) {
+ Utf2T wszUser(p.dbe.szUserId);
+ if (auto *pUser = g_chatApi.UM_FindUser(si, wszUser))
+ addNick(p, pUser->pszNick);
+ else
+ addNick(p, wszUser);
+ }
+}
+
int HistoryArray::find(MEVENT hEvent)
{
int i = 0;
diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h
index 04c7be3cd4..04e7469b50 100644
--- a/plugins/NewStory/src/history_array.h
+++ b/plugins/NewStory/src/history_array.h
@@ -143,6 +143,7 @@ public:
void addNick(ItemData &pItem, wchar_t *pwszNick);
void clear();
+ void checkGC(ItemData &pItem, SESSION_INFO *si);
int find(MEVENT hEvent);
int find(int id, int dir, const Filter &filter);
int getCount() const;