bnporc: Force marking messages as read

Because threads are in cache, the Message objects are not refreshed
after set_message_read().
Also retrieve the "seen" storage only once per call.
This commit is contained in:
Laurent Bachelier 2012-03-20 16:49:37 +01:00
commit e3bb06398c

View file

@ -127,9 +127,12 @@ class BNPorcBackend(BaseBackend, ICapBank, ICapMessages):
# the website is stupid and does not have the messages in the proper order
threads = sorted(threads, key=lambda t: t.date, reverse=True)
self._threads = threads
seen = self.storage.get('seen', default=[])
for thread in threads:
if thread.id not in self.storage.get('seen', default=[]):
if thread.id not in seen:
thread.root.flags |= thread.root.IS_UNREAD
else:
thread.root.flags &= ~thread.root.IS_UNREAD
yield thread
def fill_thread(self, thread, fields=None):