From 0a289dfb53afd6f0c70b980b730e2f411f84a1f4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 6 Feb 2020 20:29:24 +0300 Subject: MessageState: code cleaning --- plugins/ExternalAPI/m_messagestate.h | 12 ++++++------ plugins/MessageState/src/utils.cpp | 8 +++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/plugins/ExternalAPI/m_messagestate.h b/plugins/ExternalAPI/m_messagestate.h index d3dbf5b4a7..b47ea166e9 100644 --- a/plugins/ExternalAPI/m_messagestate.h +++ b/plugins/ExternalAPI/m_messagestate.h @@ -1,5 +1,11 @@ #pragma once +enum MessageReadData_TimeType +{ + MRD_TYPE_READTIME, + MRD_TYPE_MESSAGETIME +}; + struct MessageReadData { DWORD dw_lastTime; @@ -7,12 +13,6 @@ struct MessageReadData MessageReadData(DWORD lastTime, int type) : dw_lastTime(lastTime), iTimeType(type) {} }; -enum MessageReadData_TimeType -{ - MRD_TYPE_READTIME, - MRD_TYPE_MESSAGETIME -}; - /* * Update messagestate read time * WPARAM = hContact diff --git a/plugins/MessageState/src/utils.cpp b/plugins/MessageState/src/utils.cpp index e8006141a3..9dd3110133 100644 --- a/plugins/MessageState/src/utils.cpp +++ b/plugins/MessageState/src/utils.cpp @@ -13,5 +13,11 @@ time_t GetLastSentMessageTime(MCONTACT hContact) bool HasUnread(MCONTACT hContact) { - return (CheckProtoSupport(Proto_GetBaseAccountName(hContact))) && ((GetLastSentMessageTime(hContact) > g_plugin.getDword(hContact, DBKEY_MESSAGE_READ_TIME, 0)) && g_plugin.getDword(hContact, DBKEY_MESSAGE_READ_TIME, 0) != 0); + if (!CheckProtoSupport(Proto_GetBaseAccountName(hContact))) + return false; + + if (GetLastSentMessageTime(hContact) <= g_plugin.getDword(hContact, DBKEY_MESSAGE_READ_TIME, 0)) + return false; + + return g_plugin.getDword(hContact, DBKEY_MESSAGE_READ_TIME, 0) != 0; } -- cgit v1.2.3