mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2026-03-07 01:47:32 +01:00
Commit
This commit is contained in:
@@ -61,6 +61,31 @@ class Handler:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def account_settings(self, buffer, controller):
|
||||
"""Open a minimal account settings dialog for Bluesky."""
|
||||
try:
|
||||
current_mode = None
|
||||
try:
|
||||
current_mode = buffer.session.settings["general"].get("boost_mode")
|
||||
except Exception:
|
||||
current_mode = None
|
||||
ask_default = True if current_mode in (None, "ask") else False
|
||||
|
||||
from wxUI.dialogs.atprotosocial.configuration import AccountSettingsDialog
|
||||
dlg = AccountSettingsDialog(controller.view, ask_before_boost=ask_default)
|
||||
resp = dlg.ShowModal()
|
||||
if resp == wx.ID_OK:
|
||||
vals = dlg.get_values()
|
||||
boost_mode = "ask" if vals.get("ask_before_boost") else "direct"
|
||||
try:
|
||||
buffer.session.settings["general"]["boost_mode"] = boost_mode
|
||||
buffer.session.settings.write()
|
||||
except Exception:
|
||||
logger.exception("Failed to persist Bluesky boost_mode setting")
|
||||
dlg.Destroy()
|
||||
except Exception:
|
||||
logger.exception("Error opening Bluesky account settings dialog")
|
||||
|
||||
async def handle_action(self, action_name: str, user_id: str, payload: dict[str, Any]) -> dict[str, Any] | None:
|
||||
logger.debug("handle_action stub: %s %s %s", action_name, user_id, payload)
|
||||
return None
|
||||
|
||||
@@ -788,14 +788,33 @@ class Controller(object):
|
||||
text = dlg.GetValue().strip()
|
||||
dlg.Destroy()
|
||||
try:
|
||||
uri = session.send_message(text, quote_uri=item_uri)
|
||||
if uri:
|
||||
output.speak(_("Quote posted."), True)
|
||||
if text:
|
||||
uri = session.send_message(text, quote_uri=item_uri)
|
||||
if uri:
|
||||
output.speak(_("Quote posted."), True)
|
||||
else:
|
||||
output.speak(_("Failed to send quote."), True)
|
||||
else:
|
||||
output.speak(_("Failed to send quote."), True)
|
||||
# Confirm repost (share) depending on preference (boost_mode)
|
||||
ask = True
|
||||
try:
|
||||
ask = session.settings["general"].get("boost_mode", "ask") == "ask"
|
||||
except Exception:
|
||||
ask = True
|
||||
if ask:
|
||||
confirm = wx.MessageDialog(None, _("Would you like to share this post?"), _("Boost"), wx.YES_NO|wx.ICON_QUESTION)
|
||||
if confirm.ShowModal() != wx.ID_YES:
|
||||
confirm.Destroy()
|
||||
return
|
||||
confirm.Destroy()
|
||||
r_uri = session.repost(item_uri)
|
||||
if r_uri:
|
||||
output.speak(_("Post shared."), True)
|
||||
else:
|
||||
output.speak(_("Failed to share post."), True)
|
||||
except Exception:
|
||||
log.exception("Error sending Bluesky quote (invisible)")
|
||||
output.speak(_("An error occurred while posting the quote."), True)
|
||||
log.exception("Error sharing/quoting Bluesky post (invisible)")
|
||||
output.speak(_("An error occurred while sharing the post."), True)
|
||||
else:
|
||||
dlg.Destroy()
|
||||
return
|
||||
@@ -806,19 +825,38 @@ class Controller(object):
|
||||
text, files, cw_text, langs = dlg.get_payload()
|
||||
dlg.Destroy()
|
||||
try:
|
||||
uri = session.send_message(text, files=files, cw_text=cw_text, is_sensitive=bool(cw_text), languages=langs, quote_uri=item_uri)
|
||||
if uri:
|
||||
output.speak(_("Quote posted."), True)
|
||||
try:
|
||||
if hasattr(buffer, "start_stream"):
|
||||
buffer.start_stream(mandatory=False, play_sound=False)
|
||||
except Exception:
|
||||
pass
|
||||
if text or files or cw_text:
|
||||
uri = session.send_message(text, files=files, cw_text=cw_text, is_sensitive=bool(cw_text), languages=langs, quote_uri=item_uri)
|
||||
if uri:
|
||||
output.speak(_("Quote posted."), True)
|
||||
try:
|
||||
if hasattr(buffer, "start_stream"):
|
||||
buffer.start_stream(mandatory=False, play_sound=False)
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
output.speak(_("Failed to send quote."), True)
|
||||
else:
|
||||
output.speak(_("Failed to send quote."), True)
|
||||
# Confirm repost without comment depending on preference
|
||||
ask = True
|
||||
try:
|
||||
ask = session.settings["general"].get("boost_mode", "ask") == "ask"
|
||||
except Exception:
|
||||
ask = True
|
||||
if ask:
|
||||
confirm = wx.MessageDialog(self.view, _("Would you like to share this post?"), _("Boost"), wx.YES_NO|wx.ICON_QUESTION)
|
||||
if confirm.ShowModal() != wx.ID_YES:
|
||||
confirm.Destroy()
|
||||
return
|
||||
confirm.Destroy()
|
||||
r_uri = session.repost(item_uri)
|
||||
if r_uri:
|
||||
output.speak(_("Post shared."), True)
|
||||
else:
|
||||
output.speak(_("Failed to share post."), True)
|
||||
except Exception:
|
||||
log.exception("Error sending Bluesky quote (dialog)")
|
||||
output.speak(_("An error occurred while posting the quote."), True)
|
||||
log.exception("Error sharing/quoting Bluesky post (dialog)")
|
||||
output.speak(_("An error occurred while sharing the post."), True)
|
||||
else:
|
||||
dlg.Destroy()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user