Added support to delete conversations

This commit is contained in:
Manuel Cortez 2019-04-09 17:55:05 -05:00
parent 05c001067e
commit 6f245d9b7f
4 changed files with 27 additions and 4 deletions

View File

@ -6,7 +6,9 @@
* Improvements in the audio player module: * 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%. * 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. * 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) ## Changes in version 0.19 (13.03.2019)

View File

@ -883,6 +883,7 @@ class Controller(object):
else: else:
option = menu.Append(wx.NewId(), _("Discard groups")) option = menu.Append(wx.NewId(), _("Discard groups"))
widgetUtils.connect_event(menu, widgetUtils.MENU, self.unload_community_buffers, menuitem=option) 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": elif current_buffer.name == "audio_albums":
menu = wx.Menu() menu = wx.Menu()
if self.session.settings["load_at_startup"]["audio_albums"] == False and not hasattr(self.session, "audio_albums"): 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: else:
option = menu.Append(wx.NewId(), _("Discard video albums")) option = menu.Append(wx.NewId(), _("Discard video albums"))
widgetUtils.connect_event(menu, widgetUtils.MENU, self.unload_video_album_buffers, menuitem=option) 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: if menu != None:
self.window.PopupMenu(menu, self.window.FindFocus().GetPosition()) self.window.PopupMenu(menu, self.window.FindFocus().GetPosition())
@ -1001,3 +1005,12 @@ class Controller(object):
self.window.remove_buffer(buff) self.window.remove_buffer(buff)
self.buffers.remove(buffer) self.buffers.remove(buffer)
del self.session.video_albums 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)

View File

@ -64,3 +64,6 @@ def restart_program():
def community_no_items(): def community_no_items():
return wx.MessageDialog(None, _("There are 0 items for this community."), _("Error"), wx.ICON_ERROR).ShowModal() 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()

View File

@ -125,3 +125,8 @@ class communityBufferMenu(wx.Menu):
self.load_videos = load.Append(wx.NewId(), _("Load videos")) self.load_videos = load.Append(wx.NewId(), _("Load videos"))
self.load_documents = load.Append(wx.NewId(), _("Load documents")) self.load_documents = load.Append(wx.NewId(), _("Load documents"))
self.Append(wx.NewId(), _("Load"), load) 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"))