Marks read messages every two minutes
This commit is contained in:
parent
2b9aa467bd
commit
8d9082235b
@ -274,13 +274,18 @@ class empty(object):
|
||||
class chatBuffer(baseBuffer):
|
||||
|
||||
def onFocus(self, *args, **kwargs):
|
||||
pass
|
||||
msg = self.session.db[self.name]["items"][-1]
|
||||
if msg["read_state"] == 0 and msg["id"] not in self.reads:
|
||||
self.reads.append(msg["id"])
|
||||
self.session.db[self.name]["items"][-1]["read_state"] = 1
|
||||
|
||||
|
||||
def create_tab(self, parent):
|
||||
self.tab = home.chatTab(parent)
|
||||
|
||||
def connect_events(self):
|
||||
widgetUtils.connect_event(self.tab.send, widgetUtils.BUTTON_PRESSED, self.send_chat_to_user)
|
||||
self.tab.set_focus_function(self.onFocus)
|
||||
|
||||
def get_items(self, show_nextpage=False):
|
||||
retrieved = True # Control variable for handling unauthorised/connection errors.
|
||||
@ -308,6 +313,10 @@ class chatBuffer(baseBuffer):
|
||||
if text == "": return
|
||||
response = self.session.vk.client.messages.send(user_id=self.kwargs["user_id"], message=text)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(chatBuffer, self).__init__(*args, **kwargs)
|
||||
self.reads = []
|
||||
|
||||
class peopleBuffer(feedBuffer):
|
||||
|
||||
def create_tab(self, parent):
|
||||
|
@ -61,6 +61,10 @@ class Controller(object):
|
||||
self.window.insert_buffer(home.tab, _(u"Home"), self.window.search("posts"))
|
||||
self.repeatedUpdate = RepeatingTimer(180, self.update_all_buffers)
|
||||
self.repeatedUpdate.start()
|
||||
|
||||
self.readMarker = RepeatingTimer(120, self.mark_as_read)
|
||||
self.readMarker.start()
|
||||
|
||||
feed = buffers.feedBuffer(parent=self.window.tb, name="me_feed", composefunc="compose_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"])
|
||||
self.buffers.append(feed)
|
||||
self.window.insert_buffer(feed.tab, _(u"My wall"), self.window.search("posts"))
|
||||
@ -317,9 +321,19 @@ class Controller(object):
|
||||
|
||||
def set_online(self):
|
||||
r = self.session.vk.client.account.setOnline()
|
||||
print "online: %d" % (r,)
|
||||
|
||||
def create_unread_messages(self):
|
||||
msgs = self.session.vk.client.messages.getDialogs(count=200, unread=1)
|
||||
for i in msgs["items"]:
|
||||
wx.CallAfter(self.chat_from_id, i["message"]["user_id"], setfocus=False)
|
||||
|
||||
def mark_as_read(self):
|
||||
print "Marking as read"
|
||||
ids = ""
|
||||
for i in self.buffers:
|
||||
if hasattr(i, "reads"):
|
||||
for z in i.reads:
|
||||
ids = ids+"%d," % (z,)
|
||||
i.reads = []
|
||||
if ids != "":
|
||||
response = self.session.vk.client.messages.markAsRead(message_ids=ids)
|
||||
|
@ -143,6 +143,9 @@ class chatTab(wx.Panel):
|
||||
box.Add(self.text, 0, wx.ALL, 5)
|
||||
return box
|
||||
|
||||
def set_focus_function(self, focus_function):
|
||||
self.list.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, focus_function)
|
||||
|
||||
class peopleTab(homeTab):
|
||||
|
||||
def create_list(self):
|
||||
|
Loading…
Reference in New Issue
Block a user