diff --git a/src/controller/mastodon/handler.py b/src/controller/mastodon/handler.py index 6d9c524a..7507faf2 100644 --- a/src/controller/mastodon/handler.py +++ b/src/controller/mastodon/handler.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- import wx import logging +import mastodon import output +from mastodon import MastodonError from pubsub import pub from mysc import restart from mysc.thread_utils import call_threaded @@ -371,8 +373,14 @@ class Handler(object): return url = dlg.url.GetValue() bufftype = dlg.get_action() + local_api = mastodon.Mastodon(api_base_url=url) + try: + instance = local_api.instance() + except MastodonError: + commonMessageDialogs.invalid_instance() + return if bufftype == "local": - title = _(f"Local timeline for {url}") + title = _(f"Local timeline for {url.replace('https://', '')}") else: title = _(f"Federated timeline for {url}") bufftype = "public" diff --git a/src/wxUI/commonMessageDialogs.py b/src/wxUI/commonMessageDialogs.py index 62f51f2a..59fe202b 100644 --- a/src/wxUI/commonMessageDialogs.py +++ b/src/wxUI/commonMessageDialogs.py @@ -44,3 +44,6 @@ def cant_update_source() -> wx.MessageDialog: """ dlg = wx.MessageDialog(None, _("Sorry, you can't update while running {} from source.").format(application.name), _("Error"), wx.OK) return dlg.ShowModal() + +def invalid_instance(): + return wx.MessageDialog(None, _("the provided instance is invalid. Please try again."), _("Invalid instance"), wx.ICON_ERROR).ShowModal() \ No newline at end of file