diff options
author | George Hazan <george.hazan@gmail.com> | 2023-12-20 13:34:45 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-12-20 13:34:45 +0300 |
commit | e96132b4d5344d2d58d247906bcaefccfb9d5253 (patch) | |
tree | 24a9524e4900547f2ba3a461e228fd3c98c0410d /plugins/NewStory | |
parent | 4dac8bd56f9116ac76423b2664286ed894ca80c2 (diff) |
DBEVENTINFO::hContact to be returned inside an event, no need to call db_event_getContact() just after db_event_get()
Diffstat (limited to 'plugins/NewStory')
-rw-r--r-- | plugins/NewStory/src/history.h | 1 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 11 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 7 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 16 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.h | 2 |
5 files changed, 25 insertions, 12 deletions
diff --git a/plugins/NewStory/src/history.h b/plugins/NewStory/src/history.h index f71bab9fed..7bcf223d7f 100644 --- a/plugins/NewStory/src/history.h +++ b/plugins/NewStory/src/history.h @@ -18,6 +18,7 @@ enum UM_ADDEVENTFILTER, UM_REMOVEEVENT, UM_EDITEVENT, + UM_MARKREAD, UM_SELECTED, diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 2c4ce4a936..9bc64a2f81 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -369,9 +369,9 @@ void ItemData::getFontColor(int &fontId, int &colorId) const } } -void ItemData::load(bool bFullLoad) +void ItemData::load(int flags) { - if (!bFullLoad && m_bLoaded) + if (!(flags & LOAD_ALWAYS) && m_bLoaded) return; if (!fetch()) @@ -381,7 +381,8 @@ void ItemData::load(bool bFullLoad) switch (dbe.eventType) { case EVENTTYPE_MESSAGE: - markRead(); + if (!(flags & LOAD_BACK)) + markRead(); __fallthrough; case EVENTTYPE_STATUSCHANGE: @@ -639,7 +640,7 @@ int HistoryArray::find(MEVENT hEvent) return -1; } -ItemData* HistoryArray::get(int id, bool bLoad) const +ItemData* HistoryArray::get(int id, bool bLoad, bool bBack) const { int pageNo = id / HIST_BLOCK_SIZE; if (pageNo >= pages.getCount()) @@ -647,7 +648,7 @@ ItemData* HistoryArray::get(int id, bool bLoad) const auto *p = &pages[pageNo].data[id % HIST_BLOCK_SIZE]; if (bLoad && !p->m_bLoaded) - p->load(); + p->load((bBack) ? LOAD_BACK : 0); return p; } diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 1bbc623a13..00b312172d 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -10,6 +10,9 @@ enum CMStringW TplFormatString(int tpl, MCONTACT hContact, ItemData *item); +#define LOAD_ALWAYS 0x0001 +#define LOAD_BACK 0x0002 + struct ItemData { MCONTACT hContact; @@ -41,7 +44,7 @@ struct ItemData bool fetch(void); void fill(int tmpl); - void load(bool bFullLoad = false); + void load(int flags = 0); bool isLink(HWND, POINT pt, CMStringW *url = nullptr) const; bool isLinkChar(HWND, int idx) const; @@ -150,7 +153,7 @@ public: pages.insert(new ItemBlock()); } - ItemData* get(int id, bool bLoad = false) const; + ItemData* get(int id, bool bLoad = false, bool bBack = false) const; ItemData* insert(int idx); __forceinline int FindNext(int id, const Filter &filter) { return find(id, +1, filter); } diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index f56d5b4661..b2b83ebc44 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -120,7 +120,10 @@ static void __cdecl sttLoadItems(void *param) auto *pData = (NewstoryListData *)param; for (int i = pData->totalCount-1; i >= 0; i--) { - pData->LoadItem(i); + auto *pItem = pData->LoadItem(i, true); + if (pItem->dbe.eventType == EVENTTYPE_MESSAGE && !(pItem->dbe.flags & DBEF_SENT) && !pItem->dbe.markedRead()) + PostMessage(pData->m_hwnd, UM_MARKREAD, WPARAM(pItem), 0); + if ((i % 100) == 0) Sleep(50); } @@ -366,7 +369,7 @@ void NewstoryListData::EndEditItem(bool bAccept) ptrA szUtf(mir_utf8encodeW(pItem->wtext)); dbei.cbBlob = (int)mir_strlen(szUtf) + 1; - dbei.pBlob = (uint8_t *)szUtf.get(); + dbei.pBlob = szUtf.get(); db_event_edit(pItem->hEvent, &dbei); } @@ -552,13 +555,13 @@ void NewstoryListData::HitTotal(int yCurr, int yTotal) FixScrollPosition(); } -ItemData* NewstoryListData::LoadItem(int idx) +ItemData* NewstoryListData::LoadItem(int idx, bool bBack) { if (totalCount == 0) return nullptr; mir_cslock lck(m_csItems); - return (bSortAscending) ? items.get(idx, true) : items.get(totalCount - 1 - idx, true); + return (bSortAscending) ? items.get(idx, true, bBack) : items.get(totalCount - 1 - idx, true, bBack); } void NewstoryListData::OpenFolder() @@ -1105,6 +1108,11 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM } break; + case UM_MARKREAD: + if (auto *pItem = (ItemData *)wParam) + pItem->markRead(); + break; + case WM_SIZE: data->OnResize(LOWORD(lParam), HIWORD(lParam)); break; diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index f18ee1793d..619d6f01ce 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -67,7 +67,7 @@ struct NewstoryListData : public MZeroedObject void HitTotal(int yCurr, int yTotal); void LineUp(); void LineDown(); - ItemData* LoadItem(int idx); + ItemData* LoadItem(int idx, bool bBack = false); void OpenFolder(); void PageUp(); void PageDown(); |