From 70a511a1412c8f8924ec29e58bd9d13b18c78885 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Mon, 14 Jan 2019 02:23:38 -0600 Subject: [PATCH] Added settings to control creation of buffers for audio albums, video albums and community buffers at startup --- changelog.md | 1 + src/controller/mainController.py | 6 ++++++ src/interactors/configuration.py | 3 +++ src/presenters/configuration.py | 5 ++++- src/session.defaults | 7 ++++++- src/views/dialogs/configuration.py | 15 +++++++++++++++ 6 files changed, 35 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 16fe39b..715ac3b 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,7 @@ * It is possible to delete a conversation buffer from the buffer menu. Deleting a conversation will only dismiss the buffer, no data is deleted at VK. * During the first start of Socializer, an invitation will be shown to join the Socializer's group in case the current user is not already a member. * It is possible to see how many people has read a wall post when showing it in the dialog. ([#28.](https://code.manuelcortez.net/manuelcortez/socializer/issues/28)) +* A new tab has been added to the preferences dialog. From the new section, it is possible to control whether socializer should create buffers for the first 1000 audio albums, video albums and communities when starting. * Added functionality regarding comments in wall posts: * when reading a post, you can press enter in any comment to display a dialog from where it is possible to view attachments, translate, check spelling or reply to the thread. If there are replies made to this comment, these will be visible in a section called replies. Pressing enter in a reply will also open the same dialog. * A new "replies" field has been added to the comments' list. diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 5bd63eb..ffbbb6b 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -475,6 +475,8 @@ class Controller(object): time.sleep(1) def get_audio_albums(self, user_id=None, create_buffers=True): + if self.session.settings["load_at_startup"]["audio_albums"] == False: + return log.debug("Create audio albums...") if self.session.settings["vk"]["use_alternative_tokens"]: albums = self.session.vk.client_audio.get_albums(owner_id=user_id) @@ -488,6 +490,8 @@ class Controller(object): time.sleep(0.6) def get_video_albums(self, user_id=None, create_buffers=True): + if self.session.settings["load_at_startup"]["video_albums"] == False: + return log.debug("Create video albums...") albums = self.session.vk.client.video.getAlbums(owner_id=user_id) self.session.video_albums = albums["items"] @@ -509,6 +513,8 @@ class Controller(object): commonMessages.group_joined() else: log.error("Invalid result when joining the Socializer's group: %d" % (result)) + if self.session.settings["load_at_startup"]["communities"] == False: + return log.debug("Create community buffers...") groups= self.session.vk.client.groups.get(user_id=user_id, extended=1, fields="city, country, place, description, wiki_page, members_count, counters, start_date, finish_date, can_post, can_see_all_posts, activity, status, contacts, links, fixed_post, verified, site, can_create_topic", count=1000) self.session.groups=groups["items"] diff --git a/src/interactors/configuration.py b/src/interactors/configuration.py index aee4cf5..ddc6f1b 100644 --- a/src/interactors/configuration.py +++ b/src/interactors/configuration.py @@ -49,4 +49,7 @@ class configurationInteractor(base.baseInteractor): self.presenter.update_setting(section="chat", setting="open_unread_conversations", value=self.view.get_value("chat", "open_unread_conversations")) self.presenter.update_setting(section="chat", setting="automove_to_conversations", value=self.view.get_value("chat", "automove_to_conversations")) self.presenter.update_setting(section="chat", setting="notifications", value=self.presenter.get_notification_type(self.view.get_value("chat", "notifications"))) + self.presenter.update_setting(section="load_at_startup", setting="audio_albums", value=self.view.get_value("startup", "audio_albums")) + self.presenter.update_setting(section="load_at_startup", setting="video_albums", value=self.view.get_value("startup", "video_albums")) + self.presenter.update_setting(section="load_at_startup", setting="communities", value=self.view.get_value("startup", "communities")) self.presenter.save_settings_file() \ No newline at end of file diff --git a/src/presenters/configuration.py b/src/presenters/configuration.py index 88037aa..7c6a9a6 100644 --- a/src/presenters/configuration.py +++ b/src/presenters/configuration.py @@ -10,7 +10,6 @@ class configurationPresenter(base.basePresenter): self.create_config() self.run() - def get_notification_label(self, value): if value == "native": return _("Native") @@ -51,6 +50,10 @@ class configurationPresenter(base.basePresenter): self.send_message("set", tab="chat", setting="open_unread_conversations", value=self.session.settings["chat"]["open_unread_conversations"]) self.send_message("set", tab="chat", setting="automove_to_conversations", value=self.session.settings["chat"]["automove_to_conversations"]) self.send_message("set", tab="chat", setting="notifications", value=self.get_notification_label(self.session.settings["chat"]["notifications"])) + self.send_message("create_tab", tab="startup_options") + self.send_message("set", tab="startup", setting="audio_albums", value=self.session.settings["load_at_startup"]["audio_albums"]) + self.send_message("set", tab="startup", setting="video_albums", value=self.session.settings["load_at_startup"]["video_albums"]) + self.send_message("set", tab="startup", setting="communities", value=self.session.settings["load_at_startup"]["communities"]) def update_setting(self, section, setting, value): if section not in self.session.settings: diff --git a/src/session.defaults b/src/session.defaults index 8d42786..ac21004 100644 --- a/src/session.defaults +++ b/src/session.defaults @@ -27,4 +27,9 @@ notify_online = boolean(default=True) notify_offline = boolean(default=True) open_unread_conversations = boolean(default=True) automove_to_conversations = boolean(default=True) -notifications = string(default="custom") \ No newline at end of file +notifications = string(default="custom") + +[load_at_startup] +audio_albums = boolean(default=False) +video_albums = boolean(default=False) +communities = boolean(default=False) \ No newline at end of file diff --git a/src/views/dialogs/configuration.py b/src/views/dialogs/configuration.py index b262751..4bd49ef 100644 --- a/src/views/dialogs/configuration.py +++ b/src/views/dialogs/configuration.py @@ -51,6 +51,18 @@ class chat(wx.Panel, widgetUtils.BaseDialog): sizer.Add(nbox, 0, wx.ALL, 5) self.SetSizer(sizer) +class loadAtStartup(wx.Panel, widgetUtils.BaseDialog): + def __init__(self, panel): + super(loadAtStartup, self).__init__(panel) + sizer = wx.BoxSizer(wx.VERTICAL) + self.audio_albums = wx.CheckBox(self, wx.NewId(), _("Create buffers for audio albums at startup")) + sizer.Add(self.audio_albums, 0, wx.ALL, 5) + self.video_albums = wx.CheckBox(self, wx.NewId(), _("Create buffers for video albums at startup")) + sizer.Add(self.video_albums, 0, wx.ALL, 5) + self.communities = wx.CheckBox(self, wx.NewId(), _("Create buffers for communities and public pages at startup")) + sizer.Add(self.communities, 0, wx.ALL, 5) + self.SetSizer(sizer) + class configurationDialog(widgetUtils.BaseDialog): def __init__(self, title): @@ -68,6 +80,9 @@ class configurationDialog(widgetUtils.BaseDialog): self.chat = chat(self.notebook) self.notebook.AddPage(self.chat, _("Chat settings")) + def create_startup_options(self): + self.startup = loadAtStartup(self.notebook) + self.notebook.AddPage(self.startup, _("Optional buffers")) def realize(self): self.sizer.Add(self.notebook, 0, wx.ALL, 5)