From 734e5c519a9850d180fd7c441c4cda1c053e8bfc Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Sun, 2 Apr 2017 00:25:31 +0500 Subject: VKontakte: more fix multiply loading history --- protocols/VKontakte/src/misc.cpp | 5 ++++- protocols/VKontakte/src/vk_history.cpp | 6 ++++++ protocols/VKontakte/src/vk_messages.cpp | 8 ++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'protocols') diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 975e3c141a..6e59629fd9 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -719,7 +719,10 @@ int CVkProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) if (event->uType == MSG_WINDOW_EVT_OPENING && m_vkOptions.bLoadLastMessageOnMsgWindowsOpen && !isChatRoom(event->hContact) && IsHystoryMessageExist(event->hContact) != 1) { m_bNotifyForEndLoadingHistory = false; - GetServerHistory(event->hContact, 0, MAXHISTORYMIDSPERONE, 0, 0, true); + if (!getBool(event->hContact, "ActiveHistoryTask")) { + setByte(event->hContact, "ActiveHistoryTask", 1); + GetServerHistory(event->hContact, 0, MAXHISTORYMIDSPERONE, 0, 0, true); + } } return 0; diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index 503a370593..2383922618 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -24,6 +24,10 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistoryForContact(WPARAM hContact, LPAR debugLogA("CVkProto::SvcGetAllServerHistoryForContact"); if (!IsOnline()) return 0; + + if (getBool(hContact, "ActiveHistoryTask")) + return 0; + LPCWSTR str = TranslateT("Are you sure to reload all messages from vk.com?\nLocal contact history will be deleted and reloaded from the server.\nIt may take a long time.\nDo you want to continue?"); if (IDNO == MessageBoxW(NULL, str, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO)) return 0; @@ -32,6 +36,8 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistoryForContact(WPARAM hContact, LPAR if (userID == VK_INVALID_USER || userID == VK_FEED_USER) return 0; + setByte(hContact, "ActiveHistoryTask", 1); + MEVENT hDBEvent = db_event_first(hContact); while (hDBEvent) { MEVENT hDBEventNext = db_event_next(hContact, hDBEvent); diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index beb0e019e7..a54d8451aa 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -430,16 +430,20 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) int mid = jnDlg["id"].as_int(); m_bNotifyForEndLoadingHistory = false; - if (getDword(hContact, "lastmsgid", -1) == -1 && numUnread) + if (getDword(hContact, "lastmsgid", -1) == -1 && numUnread && !getBool(hContact, "ActiveHistoryTask")) { + setByte(hContact, "ActiveHistoryTask", 1); GetServerHistory(hContact, 0, numUnread, 0, 0, true); + } else GetHistoryDlg(hContact, mid); if (m_vkOptions.iMarkMessageReadOn == MarkMsgReadOn::markOnReceive && numUnread) MarkMessagesRead(hContact); } - else if (numUnread) { + else if (numUnread && !getBool(hContact, "ActiveHistoryTask")) { + m_bNotifyForEndLoadingHistory = false; + setByte(hContact, "ActiveHistoryTask", 1); GetServerHistory(hContact, 0, numUnread, 0, 0, true); if (m_vkOptions.iMarkMessageReadOn == MarkMsgReadOn::markOnReceive) -- cgit v1.2.3