summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/messages.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-12-01 22:24:48 +0000
committerRobert Pösel <robyer@seznam.cz>2014-12-01 22:24:48 +0000
commit556d6a85c9d5f4e2d29b94526689568b4081c006 (patch)
treed93c8d208bdce79d0da51c4b1873cbc38df523c9 /protocols/FacebookRM/src/messages.cpp
parentc5b2c7be9f6e35e739ad2aeb5e6d8447bd449a60 (diff)
Facebook: Optimize marking chat messages as read
Not mark as read every single message when loading history messages. git-svn-id: http://svn.miranda-ng.org/main/trunk@11206 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/messages.cpp')
-rw-r--r--protocols/FacebookRM/src/messages.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp
index d25514fb4a..fb415825be 100644
--- a/protocols/FacebookRM/src/messages.cpp
+++ b/protocols/FacebookRM/src/messages.cpp
@@ -175,21 +175,36 @@ void FacebookProto::ReadMessageWorker(void *p)
if (p == NULL)
return;
- MCONTACT hContact = (MCONTACT)p;
-
- if (getBool(FACEBOOK_KEY_KEEP_UNREAD, 0) || getBool(hContact, FACEBOOK_KEY_KEEP_UNREAD, 0))
+ if (getBool(FACEBOOK_KEY_KEEP_UNREAD, 0))
return;
- // mark message read (also send seen info)
- const char *value = (isChatRoom(hContact) ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID);
- ptrA id( getStringA(hContact, value));
- if (id == NULL)
+ std::set<MCONTACT> *hContacts = (std::set<MCONTACT>*)p;
+
+ if (hContacts->empty()) {
+ delete hContacts;
return;
+ }
- std::string data = "ids[" + utils::url::encode(std::string(id)) + "]=true";
- data += "&fb_dtsg=" + facy.dtsg_;
+ std::string data = "fb_dtsg=" + facy.dtsg_;
data += "&__user=" + facy.self_.user_id;
data += "&__a=1&__dyn=&__req=&ttstamp=" + facy.ttstamp();
+
+ for (std::set<MCONTACT>::iterator it = hContacts->begin(); it != hContacts->end(); ++it) {
+ MCONTACT hContact = *it;
+
+ if (getBool(hContact, FACEBOOK_KEY_KEEP_UNREAD, 0))
+ continue;
+
+ // mark message read (also send seen info)
+ const char *value = (isChatRoom(hContact) ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID);
+ ptrA id(getStringA(hContact, value));
+ if (id == NULL)
+ continue;
+
+ data += "&ids[" + utils::url::encode(std::string(id)) + "]=true";
+ }
+ hContacts->clear();
+ delete hContacts;
facy.flap(REQUEST_MARK_READ, &data);
}