mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-07-17 21:56:07 -04:00
created basic update profile with support for name and bio
This commit is contained in:
@@ -116,6 +116,7 @@ class Controller(object):
|
||||
# connect application events to GUI
|
||||
widgetUtils.connect_event(self.view, widgetUtils.CLOSE_EVENT, self.exit_)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.show_hide, menuitem=self.view.show_hide)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.update_profile, menuitem=self.view.updateProfile)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.search, menuitem=self.view.menuitem_search)
|
||||
# widgetUtils.connect_event(self.view, widgetUtils.MENU, self.list_manager, menuitem=self.view.lists)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.find, menuitem=self.view.find)
|
||||
@@ -1085,3 +1086,11 @@ class Controller(object):
|
||||
"""Redirects the user to the issue page on github"""
|
||||
log.debug("Redirecting the user to report an error...")
|
||||
webbrowser.open_new_tab(application.report_bugs_url)
|
||||
|
||||
def update_profile(self, *args):
|
||||
"""Updates the users profile"""
|
||||
log.debug("Update profile")
|
||||
buffer = self.get_best_buffer()
|
||||
handler = self.get_handler(buffer.session.type)
|
||||
if handler:
|
||||
handler.update_profile(buffer.session)
|
||||
|
@@ -4,10 +4,13 @@ import logging
|
||||
import output
|
||||
from pubsub import pub
|
||||
from mysc import restart
|
||||
from mysc.thread_utils import call_threaded
|
||||
from wxUI.dialogs.mastodon import search as search_dialogs
|
||||
from wxUI.dialogs.mastodon import dialogs
|
||||
from wxUI.dialogs import userAliasDialogs
|
||||
from wxUI import commonMessageDialogs
|
||||
from wxUI.dialogs.mastodon import updateProfile as update_profile_dialogs
|
||||
from sessions.mastodon.utils import html_filter
|
||||
from . import userActions, settings
|
||||
|
||||
log = logging.getLogger("controller.mastodon.handler")
|
||||
@@ -20,7 +23,7 @@ class Handler(object):
|
||||
# empty names mean the item will be Disabled.
|
||||
self.menus = dict(
|
||||
# In application menu.
|
||||
updateProfile=None,
|
||||
updateProfile=_("Update Profile"),
|
||||
menuitem_search=_("&Search"),
|
||||
lists=None,
|
||||
manageAliases=_("Manage user aliases"),
|
||||
@@ -254,4 +257,21 @@ class Handler(object):
|
||||
buffer.session.settings["user-aliases"][str(full_user.id)] = alias
|
||||
buffer.session.settings.write()
|
||||
output.speak(_("Alias has been set correctly for {}.").format(user))
|
||||
pub.sendMessage("alias-added")
|
||||
pub.sendMessage("alias-added")
|
||||
|
||||
def update_profile(self, session):
|
||||
"""Updates the users dialog"""
|
||||
profile = session.api.me()
|
||||
data = {
|
||||
'display_name': profile.display_name,
|
||||
'note': html_filter(profile.note),
|
||||
}
|
||||
dialog = update_profile_dialogs.UpdateProfileDialog(**data)
|
||||
if dialog.ShowModal() != wx.ID_OK: return
|
||||
updated_data = dialog.data
|
||||
# remove data that hasn't been updated
|
||||
for key in data:
|
||||
if data[key] == updated_data[key]:
|
||||
del updated_data[key]
|
||||
log.debug(f"Updating users profile with: {updated_data}")
|
||||
call_threaded(session.api_call, "account_update_credentials", _("Update profile"), report_success=True, **updated_data)
|
||||
|
Reference in New Issue
Block a user