Change: Added check for valid communities when creating a community timeline

This commit is contained in:
Manuel Cortez 2024-05-18 16:53:57 -06:00
parent 533f15de55
commit cd7279e83b
2 changed files with 12 additions and 1 deletions

View File

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

View File

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