From 72e13eb85e4b7aaf0ba82a2de750e1eee454bd6b Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Fri, 29 May 2015 08:45:59 +0000 Subject: VKontakte: fix comparator for notifications version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@13890 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk_feed.cpp | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'protocols') diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index bf21fdd8f2..d75ec44455 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 1 -#define __BUILD_NUM 3 +#define __BUILD_NUM 4 #include diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 1ee1c184a1..518fa08935 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -536,8 +536,20 @@ void CVkProto::RetrieveUnreadNews(time_t tLastNewsTime) } static int sttCompareVKNewsItems(const CVKNewsItem *p1, const CVKNewsItem *p2) +{ + int compareId = p1->tszId.Compare(p2->tszId); + LONG compareDate = (LONG)p1->tDate - (LONG)p2->tDate; + + return compareId ? compareDate : 0; +} + +static int sttCompareVKNotificationItems(const CVKNewsItem *p1, const CVKNewsItem *p2) { - return p1->tszId.Compare(p2->tszId) ? (LONG)p1->tDate - (LONG)p2->tDate : 0; + int compareType = p1->tszType.Compare(p2->tszType); + int compareId = p1->tszId.Compare(p2->tszId); + LONG compareDate = (LONG)p1->tDate - (LONG)p2->tDate; + + return compareType ? compareDate : (compareId ? compareDate : 0); } void CVkProto::OnReceiveUnreadNews(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) @@ -644,13 +656,11 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR const JSONNode &jnGroupInvates = jnResponse["groupinvates"]; OBJLIST vkUsers(5, NumericKeySortT); - OBJLIST vkNotification(5, sttCompareVKNewsItems); + OBJLIST vkNotification(5, sttCompareVKNotificationItems); CreateVkUserInfoList(vkUsers, jnNotifications); CreateVkUserInfoList(vkUsers, jnGroupInvates); - - if (!jnNotifications.isnull()) { const JSONNode &jnItems = jnNotifications["items"]; -- cgit v1.2.3