summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-02-06 20:29:24 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-02-06 20:29:24 +0300
commit0a289dfb53afd6f0c70b980b730e2f411f84a1f4 (patch)
tree7485f6b2a7eb7ae6cb160305a059ae41954493a1 /plugins
parent0eed72c23ea6bcd30f835de99bb6c220e2cec1ad (diff)
MessageState: code cleaning
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ExternalAPI/m_messagestate.h12
-rw-r--r--plugins/MessageState/src/utils.cpp8
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;
}