Revert "In theory, general loading times should be decreased"
This reverts commit 296b4164a7
.
This commit is contained in:
parent
bc996df3d8
commit
08d3201cee
@ -93,7 +93,7 @@ class Controller(object):
|
|||||||
player.setup()
|
player.setup()
|
||||||
self.window = mainWindow.mainWindow()
|
self.window = mainWindow.mainWindow()
|
||||||
log.debug("Main window created")
|
log.debug("Main window created")
|
||||||
self.window.change_status(_("Ready"))
|
wx.CallAfter(self.window.change_status, _("Ready"))
|
||||||
self.session = session.sessions[list(session.sessions.keys())[0]]
|
self.session = session.sessions[list(session.sessions.keys())[0]]
|
||||||
self.window.Show()
|
self.window.Show()
|
||||||
self.connect_pubsub_events()
|
self.connect_pubsub_events()
|
||||||
@ -178,9 +178,8 @@ class Controller(object):
|
|||||||
if ex.code == 6:
|
if ex.code == 6:
|
||||||
log.exception("Something went wrong when getting messages. Waiting a second to retry")
|
log.exception("Something went wrong when getting messages. Waiting a second to retry")
|
||||||
for i in msgs["items"]:
|
for i in msgs["items"]:
|
||||||
self.chat_from_id(i["last_message"]["peer_id"], setfocus=False, unread=False, getitems=False)
|
self.chat_from_id(i["last_message"]["peer_id"], setfocus=False, unread=False)
|
||||||
|
|
||||||
# @submit_to_pool_executor(thread_pool_executor)
|
|
||||||
def get_audio_albums(self, user_id=None, create_buffers=True, force_action=False):
|
def get_audio_albums(self, user_id=None, create_buffers=True, force_action=False):
|
||||||
if self.session.settings["load_at_startup"]["audio_albums"] == False and force_action == False:
|
if self.session.settings["load_at_startup"]["audio_albums"] == False and force_action == False:
|
||||||
return
|
return
|
||||||
@ -195,7 +194,6 @@ class Controller(object):
|
|||||||
for i in albums:
|
for i in albums:
|
||||||
pub.sendMessage("create_buffer", buffer_type="audioAlbum", buffer_title=_("Album: {0}").format(i["title"],), parent_tab="audio_albums", loadable=True, kwargs=dict(parent=self.window.tb, name="{0}_audio_album".format(i["id"],), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=user_id, album_id=i["id"]))
|
pub.sendMessage("create_buffer", buffer_type="audioAlbum", buffer_title=_("Album: {0}").format(i["title"],), parent_tab="audio_albums", loadable=True, kwargs=dict(parent=self.window.tb, name="{0}_audio_album".format(i["id"],), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=user_id, album_id=i["id"]))
|
||||||
|
|
||||||
@submit_to_pool_executor(thread_pool_executor)
|
|
||||||
def get_video_albums(self, user_id=None, create_buffers=True, force_action=False):
|
def get_video_albums(self, user_id=None, create_buffers=True, force_action=False):
|
||||||
if self.session.settings["load_at_startup"]["video_albums"] == False and force_action == False:
|
if self.session.settings["load_at_startup"]["video_albums"] == False and force_action == False:
|
||||||
return
|
return
|
||||||
@ -234,24 +232,25 @@ class Controller(object):
|
|||||||
self.session.db["group_info"][i["id"]*-1] = i
|
self.session.db["group_info"][i["id"]*-1] = i
|
||||||
pub.sendMessage("create_buffer", buffer_type="communityBuffer", buffer_title=i["name"], parent_tab="communities", loadable=True, get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_community".format(i["id"],), composefunc="render_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=-1*i["id"]))
|
pub.sendMessage("create_buffer", buffer_type="communityBuffer", buffer_title=i["name"], parent_tab="communities", loadable=True, get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_community".format(i["id"],), composefunc="render_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=-1*i["id"]))
|
||||||
|
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
wx.CallAfter(self.window.change_status, _("Logging in VK"))
|
wx.CallAfter(self.window.change_status, _("Logging in VK"))
|
||||||
self.session.login()
|
self.session.login()
|
||||||
wx.CallAfter(self.window.change_status, _("Ready"))
|
wx.CallAfter(self.window.change_status, _("Ready"))
|
||||||
self.create_unread_messages()
|
|
||||||
self.status_setter = RepeatingTimer(280, self.set_online)
|
|
||||||
self.status_setter.start()
|
|
||||||
self.set_online(notify=True)
|
|
||||||
call_threaded(self.get_audio_albums, self.session.user_id)
|
|
||||||
call_threaded(self.get_video_albums, self.session.user_id)
|
|
||||||
call_threaded(self.get_communities, self.session.user_id)
|
|
||||||
self.create_longpoll_thread()
|
|
||||||
for i in self.buffers:
|
for i in self.buffers:
|
||||||
if hasattr(i, "get_items"):
|
if hasattr(i, "get_items"):
|
||||||
# Translators: {0} will be replaced with the name of a buffer.
|
# Translators: {0} will be replaced with the name of a buffer.
|
||||||
wx.CallAfter(self.window.change_status, _("Loading items for {0}").format(i.name,))
|
wx.CallAfter(self.window.change_status, _("Loading items for {0}").format(i.name,))
|
||||||
i.get_items()
|
i.get_items()
|
||||||
wx.CallAfter(self.window.change_status, _("Ready"))
|
wx.CallAfter(self.window.change_status, _("Ready"))
|
||||||
|
call_threaded(self.create_unread_messages)
|
||||||
|
self.status_setter = RepeatingTimer(280, self.set_online)
|
||||||
|
self.status_setter.start()
|
||||||
|
self.set_online(notify=True)
|
||||||
|
self.get_audio_albums(self.session.user_id)
|
||||||
|
self.get_video_albums(self.session.user_id)
|
||||||
|
self.get_communities(self.session.user_id)
|
||||||
|
self.create_longpoll_thread()
|
||||||
|
|
||||||
def create_longpoll_thread(self, notify=False):
|
def create_longpoll_thread(self, notify=False):
|
||||||
try:
|
try:
|
||||||
@ -427,7 +426,7 @@ class Controller(object):
|
|||||||
"""
|
"""
|
||||||
wx.CallAfter(self.window.change_status, status)
|
wx.CallAfter(self.window.change_status, status)
|
||||||
|
|
||||||
def chat_from_id(self, user_id, setfocus=True, unread=False, getitems=True):
|
def chat_from_id(self, user_id, setfocus=True, unread=False):
|
||||||
""" Create a conversation buffer for.
|
""" Create a conversation buffer for.
|
||||||
@ user_id: Vk user, chat or community ID to chat with.
|
@ user_id: Vk user, chat or community ID to chat with.
|
||||||
@ setfocus boolean: If set to True, the buffer will receive focus automatically right after being created.
|
@ setfocus boolean: If set to True, the buffer will receive focus automatically right after being created.
|
||||||
@ -448,7 +447,7 @@ class Controller(object):
|
|||||||
elif user_id > 2000000000:
|
elif user_id > 2000000000:
|
||||||
chat = self.session.vk.client.messages.getChat(chat_id=user_id-2000000000)
|
chat = self.session.vk.client.messages.getChat(chat_id=user_id-2000000000)
|
||||||
name = chat["title"]
|
name = chat["title"]
|
||||||
pub.sendMessage("create_buffer", buffer_type="chatBuffer", buffer_title=name, parent_tab="chats", get_items=getitems, kwargs=dict(parent=self.window.tb, name="{0}_messages".format(user_id,), composefunc="render_message", parent_endpoint="messages", endpoint="getHistory", session=self.session, unread=unread, count=self.session.settings["buffers"]["count_for_chat_buffers"], peer_id=user_id, rev=0, extended=True, fields="id, user_id, date, read_state, out, body, attachments, deleted"))
|
pub.sendMessage("create_buffer", buffer_type="chatBuffer", buffer_title=name, parent_tab="chats", get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_messages".format(user_id,), composefunc="render_message", parent_endpoint="messages", endpoint="getHistory", session=self.session, unread=unread, count=self.session.settings["buffers"]["count_for_chat_buffers"], peer_id=user_id, rev=0, extended=True, fields="id, user_id, date, read_state, out, body, attachments, deleted"))
|
||||||
# if setfocus:
|
# if setfocus:
|
||||||
# pos = self.window.search(buffer.name)
|
# pos = self.window.search(buffer.name)
|
||||||
# self.window.change_buffer(pos)
|
# self.window.change_buffer(pos)
|
||||||
@ -532,7 +531,6 @@ class Controller(object):
|
|||||||
if hasattr(self, "longpoll"):
|
if hasattr(self, "longpoll"):
|
||||||
del self.longpoll
|
del self.longpoll
|
||||||
self.create_longpoll_thread(notify=True)
|
self.create_longpoll_thread(notify=True)
|
||||||
|
|
||||||
@wx_call_after
|
@wx_call_after
|
||||||
def create_buffer(self, buffer_type="baseBuffer", buffer_title="", parent_tab=None, loadable=False, get_items=False, kwargs={}):
|
def create_buffer(self, buffer_type="baseBuffer", buffer_title="", parent_tab=None, loadable=False, get_items=False, kwargs={}):
|
||||||
""" Create and insert a buffer in the specified place.
|
""" Create and insert a buffer in the specified place.
|
||||||
@ -542,8 +540,6 @@ class Controller(object):
|
|||||||
@loadable bool: If set to True, the new buffer will not be able to load contents until can_get_items will be set to True.
|
@loadable bool: If set to True, the new buffer will not be able to load contents until can_get_items will be set to True.
|
||||||
@get_items bool: If set to True, get_items will be called inmediately after creating the buffer.
|
@get_items bool: If set to True, get_items will be called inmediately after creating the buffer.
|
||||||
"""
|
"""
|
||||||
self.newtime = time.time()
|
|
||||||
log.debug("Creating buffer of type {0} with args {1}".format(buffer_type, kwargs))
|
|
||||||
if not hasattr(buffers, buffer_type):
|
if not hasattr(buffers, buffer_type):
|
||||||
raise AttributeError("Specified buffer type does not exist: %s" % (buffer_type,))
|
raise AttributeError("Specified buffer type does not exist: %s" % (buffer_type,))
|
||||||
buffer = getattr(buffers, buffer_type)(**kwargs)
|
buffer = getattr(buffers, buffer_type)(**kwargs)
|
||||||
@ -554,7 +550,6 @@ class Controller(object):
|
|||||||
self.window.add_buffer(buffer.tab, buffer_title)
|
self.window.add_buffer(buffer.tab, buffer_title)
|
||||||
else:
|
else:
|
||||||
self.window.insert_buffer(buffer.tab, buffer_title, self.window.search(parent_tab))
|
self.window.insert_buffer(buffer.tab, buffer_title, self.window.search(parent_tab))
|
||||||
log.debug("Buffer created in {} seconds".format(time.time()-self.newtime))
|
|
||||||
if get_items:
|
if get_items:
|
||||||
call_threaded(buffer.get_items)
|
call_threaded(buffer.get_items)
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class audioMenu(wx.Menu):
|
|||||||
self.move = self.Append(wx.NewId(), _("Move to album"))
|
self.move = self.Append(wx.NewId(), _("Move to album"))
|
||||||
self.download = self.Append(wx.NewId(), _("Download"))
|
self.download = self.Append(wx.NewId(), _("Download"))
|
||||||
self.select = self.Append(wx.NewId(), _("Select all"))
|
self.select = self.Append(wx.NewId(), _("Select all"))
|
||||||
self.deselect = self.Append(wx.NewId(), _("Deselect all"))
|
self.unselect = self.Append(wx.NewId(), _("Unselect all"))
|
||||||
|
|
||||||
class peopleMenu(wx.Menu):
|
class peopleMenu(wx.Menu):
|
||||||
def __init__(self, is_request=False, is_subscriber=False, not_friend=False, *args, **kwargs):
|
def __init__(self, is_request=False, is_subscriber=False, not_friend=False, *args, **kwargs):
|
||||||
@ -107,9 +107,3 @@ class conversationBufferMenu(wx.Menu):
|
|||||||
super(conversationBufferMenu, self).__init__()
|
super(conversationBufferMenu, self).__init__()
|
||||||
self.delete = self.Append(wx.NewId(), _("Delete conversation"))
|
self.delete = self.Append(wx.NewId(), _("Delete conversation"))
|
||||||
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
|
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
|
||||||
|
|
||||||
class messageMenu(wx.Menu):
|
|
||||||
def __init__(self):
|
|
||||||
super(messageMenu, self).__init__()
|
|
||||||
self.forward = self.Append(wx.NewId(), _("Forward"))
|
|
||||||
self.delete = self.Append(wx.NewId(), _("Delete"))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user