From 420da4e31280e87980178893e8b0ed8f9e90cf7a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 10 Mar 2024 15:03:50 +0300 Subject: NewStory: fix for #4275 --- plugins/NewStory/src/history_array.cpp | 20 +++++++++----------- plugins/NewStory/src/history_array.h | 8 ++++---- plugins/NewStory/src/history_control.cpp | 13 ++++++++++--- plugins/NewStory/src/history_control.h | 1 + 4 files changed, 24 insertions(+), 18 deletions(-) (limited to 'plugins') diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 7eb13d31fa..8fbcee0ed9 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -389,7 +389,7 @@ void ItemData::load(bool bLoadAlways) switch (dbe.eventType) { case EVENTTYPE_MESSAGE: - markRead(); + pOwner->MarkRead(this); __fallthrough; case EVENTTYPE_STATUSCHANGE: @@ -418,7 +418,7 @@ void ItemData::load(bool bLoadAlways) buf.AppendFormat(TranslateT(" %u KB"), size < 1024 ? 1 : unsigned(blob.getSize() / 1024)); wtext = buf.Detach(); - markRead(); + pOwner->MarkRead(this); break; } @@ -475,12 +475,6 @@ void ItemData::load(bool bLoadAlways) dbe.unload(); } -void ItemData::markRead() -{ - if (!(dbe.flags & DBEF_SENT)) - dbe.wipeNotify(); -} - void ItemData::setText(HWND hwnd) { if (data) @@ -513,10 +507,11 @@ void HistoryArray::clear() iLastPageCounter = 0; } -void HistoryArray::addChatEvent(SESSION_INFO *si, const LOGINFO *lin) +void HistoryArray::addChatEvent(NewstoryListData *pOwner, SESSION_INFO *si, const LOGINFO *lin) { int numItems = getCount(); auto &p = allocateItem(); + p.pOwner = pOwner; p.hContact = si->hContact; if (si->pMI->bDatabase && lin->hEvent) { @@ -568,7 +563,7 @@ void HistoryArray::addChatEvent(SESSION_INFO *si, const LOGINFO *lin) } } -bool HistoryArray::addEvent(MCONTACT hContact, MEVENT hEvent, int count) +bool HistoryArray::addEvent(NewstoryListData *pOwner, MCONTACT hContact, MEVENT hEvent, int count) { if (count == -1) count = MAXINT; @@ -582,6 +577,7 @@ bool HistoryArray::addEvent(MCONTACT hContact, MEVENT hEvent, int count) if (count == 1) { auto &p = allocateItem(); + p.pOwner = pOwner; p.hContact = hContact; p.dbe = hEvent; if (si) { @@ -598,6 +594,7 @@ bool HistoryArray::addEvent(MCONTACT hContact, MEVENT hEvent, int count) break; auto &p = allocateItem(); + p.pOwner = pOwner; p.hContact = hContact; p.dbe = hEvent; if (si) { @@ -620,13 +617,14 @@ void HistoryArray::addNick(ItemData &pItem, wchar_t *pwszNick) } } -void HistoryArray::addResults(const OBJLIST &pArray) +void HistoryArray::addResults(NewstoryListData *pOwner, const OBJLIST &pArray) { int numItems = getCount(); auto *pPrev = (numItems == 0) ? nullptr : get(numItems - 1); for (auto &it : pArray) { auto &p = allocateItem(); + p.pOwner = pOwner; p.hContact = it->hContact; p.dbe = it->hEvent; p.m_bIsResult = true; diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 3806062859..00482f76c2 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -24,6 +24,7 @@ struct ItemData DB::EventInfo dbe; wchar_t *wtext; wchar_t *wszNick; + struct NewstoryListData *pOwner; HText data; @@ -34,7 +35,6 @@ struct ItemData ItemData* checkPrev(ItemData *pPrev, HWND hwnd); ItemData* checkPrevGC(ItemData *pPrev, HWND hwnd); void checkCreate(HWND hwnd); - void markRead(); void setText(HWND hwnd); bool completed() const { return m_bOfflineDownloaded == 100; } @@ -136,9 +136,9 @@ public: HistoryArray(); ~HistoryArray(); - bool addEvent(MCONTACT hContact, MEVENT hEvent, int count); - void addChatEvent(SESSION_INFO *si, const LOGINFO *pEvent); - void addResults(const OBJLIST &pArray); + bool addEvent(NewstoryListData *pOwner, MCONTACT hContact, MEVENT hEvent, int count); + void addChatEvent(NewstoryListData *pOwner, SESSION_INFO *si, const LOGINFO *pEvent); + void addResults(NewstoryListData *pOwner, const OBJLIST &pArray); void addNick(ItemData &pItem, wchar_t *pwszNick); void clear(); diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 09a9c36319..473f9f99e1 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -113,7 +113,7 @@ void NewstoryListData::AddChatEvent(SESSION_INFO *si, const LOGINFO *lin) return; ScheduleDraw(); - items.addChatEvent(si, lin); + items.addChatEvent(this, si, lin); totalCount++; } @@ -122,7 +122,7 @@ void NewstoryListData::AddChatEvent(SESSION_INFO *si, const LOGINFO *lin) void NewstoryListData::AddEvent(MCONTACT hContact, MEVENT hFirstEvent, int iCount) { ScheduleDraw(); - items.addEvent(hContact, hFirstEvent, iCount); + items.addEvent(this, hContact, hFirstEvent, iCount); totalCount = items.getCount(); } @@ -131,7 +131,7 @@ void NewstoryListData::AddEvent(MCONTACT hContact, MEVENT hFirstEvent, int iCoun void NewstoryListData::AddResults(const OBJLIST &results) { ScheduleDraw(); - items.addResults(results); + items.addResults(this, results); totalCount = items.getCount(); } @@ -624,6 +624,12 @@ ItemData* NewstoryListData::LoadItem(int idx) return (bSortAscending) ? items.get(idx, true) : items.get(totalCount - 1 - idx, true); } +void NewstoryListData::MarkRead(ItemData *pItem) +{ + if (pMsgDlg) + pMsgDlg->MarkEventRead(pItem->dbe); +} + void NewstoryListData::OpenFolder() { if (auto *pItem = GetItem(caret)) { @@ -928,6 +934,7 @@ void NewstoryListData::TryUp(int iCount) break; auto *p = items.insert(0); + p->pOwner = this; p->hContact = hContact; p->dbe = hPrev; totalCount++; diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index 9563827aa5..95cfc44dc7 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -72,6 +72,7 @@ struct NewstoryListData : public MZeroedObject void LineUp(); void LineDown(); ItemData* LoadItem(int idx); + void MarkRead(ItemData *pItem); void OpenFolder(); void PageUp(); void PageDown(); -- cgit v1.2.3