diff options
Diffstat (limited to 'plugins/NewStory')
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 36 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 7 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 2 |
3 files changed, 28 insertions, 17 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index f05ac90363..5b80cc4e52 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -54,10 +54,9 @@ bool Filter::check(ItemData *item) const } } - if (flags & (EVENTTEXT | EVENTONLY)) { - item->load(true); + if (flags & (EVENTTEXT | EVENTONLY)) return CheckFilter(item->getWBuf(), text); - } + return true; }; @@ -102,7 +101,7 @@ ItemData* ItemData::checkPrev(ItemData *pPrev) return this; // we don't group anything but messages - if (db_event_get(hEvent, &dbe)) + if (!fetch()) return this; if (dbe.eventType != EVENTTYPE_MESSAGE) @@ -216,6 +215,22 @@ bool ItemData::isLinkChar(int idx) const return ((res & CFM_LINK) && (cf.dwEffects & CFE_LINK)) || ((res & CFM_REVISED) && (cf.dwEffects & CFE_REVISED)); } +bool ItemData::fetch(void) +{ + // if this event is virtual (for example, in group chats), don't try to laod it + if (!hEvent) + return true; + + if (!dbe) { + if (!dbe.fetch(hEvent)) + return false; + + if (dbe.szReplyId) + dbe.szReplyId = mir_strdup(dbe.szReplyId); + } + return true; +} + void ItemData::fill(int tmpl) { switch (tmpl) { @@ -330,15 +345,11 @@ void ItemData::load(bool bFullLoad) if (!bFullLoad && m_bLoaded) return; - dbe.cbBlob = -1; - if (db_event_get(hEvent, &dbe)) + if (!fetch()) return; m_bLoaded = true; - if (dbe.szReplyId) - dbe.szReplyId = mir_strdup(dbe.szReplyId); - switch (dbe.eventType) { case EVENTTYPE_MESSAGE: if (!(dbe.flags & DBEF_SENT)) { @@ -427,8 +438,7 @@ void ItemData::load(bool bFullLoad) } } - mir_free(dbe.pBlob); - dbe.pBlob = nullptr; + dbe.unload(); } void ItemData::setText() @@ -470,7 +480,7 @@ void HistoryArray::addChatEvent(SESSION_INFO *si, const LOGINFO *lin) if (si->pMI->bDatabase && lin->hEvent) { p.hEvent = lin->hEvent; - p.load(true); + p.load(); } else { CMStringW wszText; @@ -599,7 +609,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(true); + p->load(); return p; } diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 18fff3217c..b1f5a12e2c 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -36,8 +36,9 @@ struct ItemData void checkCreate(HWND hwnd); void setText(); + bool fetch(void); void fill(int tmpl); - void load(bool bFullLoad); + void load(bool bFullLoad = false); bool isLink(POINT pt, CMStringW *url = nullptr) const; bool isLinkChar(int idx) const; @@ -49,9 +50,9 @@ struct ItemData CMStringW formatString() { return TplFormatString(getTemplate(), hContact, this); } CMStringW formatStringEx(wchar_t *sztpl); - inline wchar_t *getWBuf() + inline wchar_t* getWBuf() { - load(true); + load(); return wtext; } }; diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index f62e85491e..60687e79df 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -929,7 +929,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case UM_EDITEVENT: idx = data->items.find(lParam); if (idx != -1) { - auto *p = data->LoadItem(idx); + auto *p = data->GetItem(idx); p->load(true); p->setText(); InvalidateRect(hwnd, 0, FALSE); |