diff options
author | George Hazan <ghazan@miranda.im> | 2020-06-16 18:04:35 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-06-16 18:04:35 +0300 |
commit | 3d8b3afe4f9b20bf8b393987e4f618ba3159b79d (patch) | |
tree | d29da35edd7d7bdf6a8c63954f9658b1642cbd51 | |
parent | ad6af9adc1a8036ba75a4053bcfc51beb84632bb (diff) |
Clist_Modern: fix for sorting by last message time
-rw-r--r-- | plugins/Clist_modern/src/modern_clc.cpp | 4 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_contact.cpp | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index 27b0dbbbdb..828ee36779 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -162,8 +162,10 @@ static int clcHookDbEventAdded(WPARAM hContact, LPARAM hDbEvent) if ((dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE) && !(dbei.flags & DBEF_SENT)) {
g_plugin.setDword(hContact, "mf_lastmsg", dbei.timestamp);
ClcCacheEntry *pdnce = Clist_GetCacheEntry(hContact);
- if (pdnce)
+ if (pdnce) {
pdnce->dwLastMsgTime = dbei.timestamp;
+ Clist_Broadcast(CLM_AUTOREBUILD, hContact, 0);
+ }
}
}
return 0;
diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp index 53a4ba2e22..eb4285f2eb 100644 --- a/plugins/Clist_modern/src/modern_contact.cpp +++ b/plugins/Clist_modern/src/modern_contact.cpp @@ -119,7 +119,12 @@ int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2) break;
case SORTBY_LASTMSG: // last message
- r = (int)CompareContacts2_getLMTime(contact2->hContact) - (int)CompareContacts2_getLMTime(contact1->hContact);
+ if (c1->dwLastMsgTime == -1) c1->dwLastMsgTime = CompareContacts2_getLMTime(contact1->hContact);
+ if (c2->dwLastMsgTime == -1) c2->dwLastMsgTime = CompareContacts2_getLMTime(contact2->hContact);
+ if (c1->dwLastMsgTime == c2->dwLastMsgTime)
+ continue;
+
+ r = (c1->dwLastMsgTime < c2->dwLastMsgTime) ? 1 : -1; // reverse sort order
break;
case SORTBY_PROTO:
|