From 0407b43e6cab29046775ecaf73b31f2a7ee3b95b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 4 Jun 2017 21:59:58 +0300 Subject: RecentContacts: we better skip old events --- plugins/RecentContacts/src/RecentContacts.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'plugins/RecentContacts/src') diff --git a/plugins/RecentContacts/src/RecentContacts.cpp b/plugins/RecentContacts/src/RecentContacts.cpp index ea91373e63..c707f81ed1 100644 --- a/plugins/RecentContacts/src/RecentContacts.cpp +++ b/plugins/RecentContacts/src/RecentContacts.cpp @@ -378,6 +378,13 @@ INT_PTR CALLBACK ShowListMainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM return FALSE; } +static __time64_t GetLastUsedTimeStamp(MCONTACT hContact) +{ + return + ((__time64_t)db_get_dw(hContact, MODULENAME, dbLastUC_LastUsedTimeLo, -1)) | + (((__time64_t)db_get_dw(hContact, MODULENAME, dbLastUC_LastUsedTimeHi, -1)) << 32); +} + INT_PTR OnMenuCommandShowList(WPARAM, LPARAM) { cmultimap *contacts = new cmultimap; @@ -387,8 +394,7 @@ INT_PTR OnMenuCommandShowList(WPARAM, LPARAM) dbe.pBlob = buf; for (MCONTACT curContact = db_find_first(); curContact != NULL; curContact = db_find_next(curContact)) { - __time64_t curTime = ((__time64_t)db_get_dw(curContact, MODULENAME, dbLastUC_LastUsedTimeLo, -1)) | - (((__time64_t)db_get_dw(curContact, MODULENAME, dbLastUC_LastUsedTimeHi, -1)) << 32); + __time64_t curTime = GetLastUsedTimeStamp(curContact); MEVENT curEvent = db_event_last(curContact); if (curEvent != NULL) { @@ -472,8 +478,12 @@ static int OnGCInEvent(WPARAM, LPARAM lParam) GCEVENT *gce = (GCEVENT*)lParam; if (gce->pDest->iType == GC_EVENT_MESSAGE) { SESSION_INFO *si = pci->SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); - if (si && si->hContact) + if (si && si->hContact) { + // skip old events + if (gce->time && gce->time <= GetLastUsedTimeStamp(si->hContact)) + return 0; SaveLastUsedTimeStamp(si->hContact); + } } return 0; } -- cgit v1.2.3