diff options
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 20 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index a7cdcde421..f56d5b4661 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -112,13 +112,32 @@ void NewstoryListData::AddChatEvent(SESSION_INFO *si, const LOGINFO *lin) totalCount++; } +///////////////////////////////////////////////////////////////////////////////////////// + +static void __cdecl sttLoadItems(void *param) +{ + SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_BEGIN); + + auto *pData = (NewstoryListData *)param; + for (int i = pData->totalCount-1; i >= 0; i--) { + pData->LoadItem(i); + if ((i % 100) == 0) + Sleep(50); + } +} + void NewstoryListData::AddEvent(MCONTACT hContact, MEVENT hFirstEvent, int iCount) { ScheduleDraw(); items.addEvent(hContact, hFirstEvent, iCount); totalCount = items.getCount(); + + if (iCount == -1) + mir_forkthread(sttLoadItems, this); } +///////////////////////////////////////////////////////////////////////////////////////// + void NewstoryListData::AddResults(const OBJLIST<SearchResult> &results) { ScheduleDraw(); @@ -538,6 +557,7 @@ ItemData* NewstoryListData::LoadItem(int idx) if (totalCount == 0) return nullptr; + mir_cslock lck(m_csItems); return (bSortAscending) ? items.get(idx, true) : items.get(totalCount - 1 - idx, true); } diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index 463bfe15c2..f18ee1793d 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -7,6 +7,7 @@ struct NewstoryListData : public MZeroedObject { NewstoryListData(HWND); + mir_cs m_csItems; HistoryArray items; int scrollTopItem; // topmost item |