Started some kind of implementation

This commit is contained in:
Manuel Cortez 2019-10-11 17:39:19 -05:00
parent 63def5530f
commit 9e6e72c0a1
5 changed files with 40 additions and 6 deletions

View File

@ -1552,4 +1552,14 @@ class requestsBuffer(peopleBuffer):
msg = _("{0} {1} is following you.").format(person["first_name"], person["last_name"])
pub.sendMessage("notify", message=msg)
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
class notificationBuffer(feedBuffer):
def create_tab(self, parent):
self.tab = home.notificationTab(parent)
self.connect_events()
self.tab.name = self.name
def onFocus(self, event, *args, **kwargs):
event.Skip()

View File

@ -133,6 +133,7 @@ class Controller(object):
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Pending requests"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests", composefunc="render_person", session=self.session, count=1000, fields="can_post"))
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("I follow"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests_sent", composefunc="render_person", session=self.session, count=1000, out=1, fields="can_post"))
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Subscribers"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="subscribers", composefunc="render_person", session=self.session, count=1000, need_viewed=1, fields="can_post"))
# pub.sendMessage("create_buffer", buffer_type="notificationBuffer", buffer_title=_("Notifications"), parent_tab=None, loadable=False, kwargs=dict(parent=self.window.tb, name="notifications", composefunc="render_notification", session=self.session, endpoint="get", parent_endpoint="notifications", count=100, filters="wall,mentions,comments,likes,reposted,followers,friends"))
pub.sendMessage("create_buffer", buffer_type="documentBuffer", buffer_title=_("Documents"), parent_tab=None, loadable=True, kwargs=dict(parent=self.window.tb, name="documents", composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs"))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Groups"), kwargs=dict(parent=self.window.tb, name="communities"))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Chats"), kwargs=dict(parent=self.window.tb, name="chats"))

View File

@ -280,4 +280,22 @@ def render_document(document, session):
size = convert_bytes(document["size"])
date = arrow.get(document["date"]).humanize(locale=languageHandler.curLang[:2])
doc_type = doc_types[document["type"]]
return [user["user1_nom"], title, doc_type, size, date]
return [user["user1_nom"], title, doc_type, size, date]
def render_notification(notification, session):
notification.pop("hide_buttons")
print(notification["icon_type"])
# print(notification["header"])
print(notification)
date = arrow.get(notification["date"]).humanize(locale=languageHandler.curLang[:2])
msg = notification["header"]
# msg = notification["header"]
# if notification["type"] == "follow":
# if len(notification["feedback"]) == 1:
# user = session.get_user(notification["feedback"][0])
# msg = _("{user1_nom} subscribed to your account").format(**user)
# else:
# users = ["{first_name} {last_name},".format(first_name=user["first_name"], last_name=user["last_name"]) for user in notification["feedback"]]
# msg = " ".join(users)
# print(msg)
return [msg, date]

View File

@ -207,6 +207,9 @@ class vkSession(object):
else:
kwargs.update(offset=0)
formatted_endpoint = "{formatted_endpoint}.{new_path}".format(formatted_endpoint=formatted_endpoint, new_path=endpoint)
offset_deprecated = ["notifications.get"]
if formatted_endpoint in offset_deprecated:
kwargs.update(offset=None)
log.debug("Calling endpoint %s with params %r" % (formatted_endpoint, kwargs,))
data = getattr(p, endpoint)(*args, **kwargs)
if data != None:
@ -218,7 +221,8 @@ class vkSession(object):
data["items"].reverse()
if type(data) == dict:
num = self.order_buffer(name, data["items"], show_nextpage)
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"]
if formatted_endpoint not in offset_deprecated:
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"]
if len(data["items"]) > 0 and "first_name" in data["items"][0]:
data2 = {"profiles": [], "groups": []}
for i in data["items"]:

View File

@ -100,9 +100,9 @@ class audioAlbumTab(audioTab):
self.postBox.Add(self.play, 0, wx.ALL, 5)
self.postBox.Add(self.play_all, 0, wx.ALL, 5)
class notificationsTab(homeTab):
class notificationTab(homeTab):
def __init__(self, parent):
super(notificationsTab, self).__init__(parent=parent)
super(notificationTab, self).__init__(parent=parent)
self.name = "notifications"
def OnKeyDown(self, ev=None):
@ -110,7 +110,8 @@ class notificationsTab(homeTab):
ev.Skip()
def create_list(self):
self.list = widgetUtils.list(self, *[_("Notification")], style=wx.LC_REPORT)
self.lbl = wx.StaticText(self, wx.NewId(), _("Po&sts"))
self.list = widgetUtils.list(self, *[_("Notification"), _("Date")], style=wx.LC_REPORT)
self.list.set_windows_size(0, 190)
self.list.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnKeyDown)