diff --git a/changelog.md b/changelog.md index 66e613f..c7265f7 100644 --- a/changelog.md +++ b/changelog.md @@ -6,7 +6,9 @@ * Improvements in the audio player module: * When modifying volume of the playing audio, it will decrease or increase the volume by 2% instead of 5%. * For users with multiple soundcards, there is a new tab in the preferences dialogue of Socializer, called sound. From there, you can define what soundcard will be used for input and output. -* it is possible to retrieve more items for conversation buffers. Due to API limitations, it is possible to load up to the last 600 messages for every conversation. Take into account that the process of loading more items takes some time. You will hear a message when the process is done. +* Improvements in conversation buffers: + * it is possible to retrieve more items for conversation buffers. Due to API limitations, it is possible to load up to the last 600 messages for every conversation. Take into account that the process of loading more items takes some time. You will hear a message when the process is done. + * It is possible to delete entire conversations from the tree of buffers, by using the menu key and selecting "delete conversation". The conversation will be removed from VK. ## Changes in version 0.19 (13.03.2019) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index c75bb38..ebdee22 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -883,6 +883,7 @@ class Controller(object): else: option = menu.Append(wx.NewId(), _("Discard groups")) widgetUtils.connect_event(menu, widgetUtils.MENU, self.unload_community_buffers, menuitem=option) + # Deal with video and audio albums' sections. elif current_buffer.name == "audio_albums": menu = wx.Menu() if self.session.settings["load_at_startup"]["audio_albums"] == False and not hasattr(self.session, "audio_albums"): @@ -899,6 +900,9 @@ class Controller(object): else: option = menu.Append(wx.NewId(), _("Discard video albums")) widgetUtils.connect_event(menu, widgetUtils.MENU, self.unload_video_album_buffers, menuitem=option) + elif current_buffer.name.endswith("_messages"): + menu = menus.conversationBufferMenu() + widgetUtils.connect_event(menu, widgetUtils.MENU, self.delete_conversation, menuitem=menu.delete) if menu != None: self.window.PopupMenu(menu, self.window.FindFocus().GetPosition()) @@ -1000,4 +1004,13 @@ class Controller(object): buff = self.window.search(buffer.name) self.window.remove_buffer(buff) self.buffers.remove(buffer) - del self.session.video_albums \ No newline at end of file + del self.session.video_albums + + def delete_conversation(self, *args, **kwargs): + current_buffer = self.get_current_buffer() + d = commonMessages.delete_conversation() + if d == widgetUtils.YES: + results = self.session.vk.client.messages.deleteConversation(peer_id=current_buffer.kwargs["peer_id"]) + buff = self.window.search(current_buffer.name) + self.window.remove_buffer(buff) + self.buffers.remove(current_buffer) \ No newline at end of file diff --git a/src/wxUI/commonMessages.py b/src/wxUI/commonMessages.py index 321d078..f603385 100644 --- a/src/wxUI/commonMessages.py +++ b/src/wxUI/commonMessages.py @@ -63,4 +63,7 @@ def restart_program(): return wx.MessageDialog(None, _("In order to apply the changes you requested, you must restart the program. Do you want to restart Socializer now?"), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal() def community_no_items(): - return wx.MessageDialog(None, _("There are 0 items for this community."), _("Error"), wx.ICON_ERROR).ShowModal() \ No newline at end of file + return wx.MessageDialog(None, _("There are 0 items for this community."), _("Error"), wx.ICON_ERROR).ShowModal() + +def delete_conversation(): + return wx.MessageDialog(None, _("do you really want to delete all messages of this conversation in VK?"), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal() diff --git a/src/wxUI/menus.py b/src/wxUI/menus.py index f185965..36c1ed9 100644 --- a/src/wxUI/menus.py +++ b/src/wxUI/menus.py @@ -124,4 +124,9 @@ class communityBufferMenu(wx.Menu): self.load_audios = load.Append(wx.NewId(), _("Load audios")) self.load_videos = load.Append(wx.NewId(), _("Load videos")) self.load_documents = load.Append(wx.NewId(), _("Load documents")) - self.Append(wx.NewId(), _("Load"), load) \ No newline at end of file + self.Append(wx.NewId(), _("Load"), load) + +class conversationBufferMenu(wx.Menu): + def __init__(self): + super(conversationBufferMenu, self).__init__() + self.delete = self.Append(wx.NewId(), _("Delete conversation")) \ No newline at end of file