Update some info when focusing an item in the list of posts

This commit is contained in:
Manuel Cortez 2016-06-05 14:15:40 -05:00
parent 24140f9e42
commit f30a099bf4
3 changed files with 31 additions and 2 deletions

View File

@ -7,8 +7,9 @@
* It's possible to open a friends timeline for others.
* Fixed some strange bugs in the built version.
* Deactivated accounts will not cause problems in friends lists. They will be displayed as deactivated, wich means that it'll be impossible to interact with those accounts.
* When opened, the client will set online for the user account, it'll inform VK that this user is currently online. This parameter will be updated every 15 minutes, as stated in the API documentation. When exiting, Socializer will try to set the account as offline.
* When opened, the client will set online for the user account, it'll inform VK that this user is currently online. This parameter will be updated every 15 minutes, as stated in the API documentation. When exiting, Socializer will try to set the account as offline. Friends and other people could use this parameter to see if you are using VK in the moment.
* When opened, socializer will try to create chat buffers for all unread messages.
* Update some information on certain posts when an item is selected. For example, update the date of a post.
## Changes on build 2016.05.25

View File

@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
import languageHandler
import arrow
import wx
import widgetUtils
import messages
@ -111,6 +113,7 @@ class baseBuffer(object):
def connect_events(self):
widgetUtils.connect_event(self.tab.post, widgetUtils.BUTTON_PRESSED, self.post)
widgetUtils.connect_event(self.tab.list.list, widgetUtils.KEYPRESS, self.get_event)
self.tab.set_focus_function(self.onFocus)
def get_event(self, ev):
if ev.GetKeyCode() == wx.WXK_RETURN and ev.ControlDown() and ev.ShiftDown(): event = "pause_audio"
@ -161,6 +164,15 @@ class baseBuffer(object):
else:
return [post["source_id"]]
def onFocus(self, *args,**kwargs):
""" Function executed when the item in a list is selected.
For this buffer it updates the date of posts in the list."""
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
original_date = arrow.get(post["date"])
created_at = original_date.humanize(locale=languageHandler.getLanguage())
self.tab.list.list.SetStringItem(self.tab.list.get_selected(), 2, created_at)
class feedBuffer(baseBuffer):
def get_items(self, show_nextpage=False):
@ -242,6 +254,9 @@ class audioBuffer(feedBuffer):
def get_more_items(self, *args, **kwargs):
output.speak(_(u"This buffer doesn't support getting more items."))
def onFocus(self, *args, **kwargs):
pass
class empty(object):
def __init__(self, name=None, parent=None, *args, **kwargs):
@ -258,6 +273,9 @@ class empty(object):
class chatBuffer(baseBuffer):
def onFocus(self, *args, **kwargs):
pass
def create_tab(self, parent):
self.tab = home.chatTab(parent)
@ -302,3 +320,10 @@ class peopleBuffer(feedBuffer):
def new_chat(self, *args, **kwargs):
user_id = self.session.db[self.name]["items"][self.tab.list.get_selected()]["id"]
pub.sendMessage("new-chat", user_id=user_id)
def onFocus(self, *args, **kwargs):
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
if post.has_key("last_seen") == False: return
original_date = arrow.get(post["last_seen"]["time"])
created_at = original_date.humanize(locale=languageHandler.getLanguage())
self.tab.list.list.SetStringItem(self.tab.list.get_selected(), 1, created_at)

View File

@ -43,6 +43,9 @@ class homeTab(wx.Panel):
if ev.GetKeyCode() == wx.WXK_WINDOWS_MENU:
pub.sendMessage("show-menu", position=self.results.list.GetPosition())
def set_focus_function(self, focus_function):
self.list.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, focus_function)
class feedTab(homeTab):
def __init__(self, parent):
super(feedTab, self).__init__(parent=parent)