created basic update profile with support for name and bio

This commit is contained in:
Abdulqadir Ahmad
2023-06-08 00:40:38 +01:00
parent 61525023ce
commit 453630e655
4 changed files with 88 additions and 3 deletions

View File

@@ -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)