mirror of
				https://github.com/MCV-Software/TWBlue.git
				synced 2025-11-04 05:47:05 +00:00 
			
		
		
		
	Change: Added check for valid communities when creating a community timeline
This commit is contained in:
		@@ -1,7 +1,9 @@
 | 
				
			|||||||
# -*- coding: utf-8 -*-
 | 
					# -*- coding: utf-8 -*-
 | 
				
			||||||
import wx
 | 
					import wx
 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
 | 
					import mastodon
 | 
				
			||||||
import output
 | 
					import output
 | 
				
			||||||
 | 
					from mastodon import MastodonError
 | 
				
			||||||
from pubsub import pub
 | 
					from pubsub import pub
 | 
				
			||||||
from mysc import restart
 | 
					from mysc import restart
 | 
				
			||||||
from mysc.thread_utils import call_threaded
 | 
					from mysc.thread_utils import call_threaded
 | 
				
			||||||
@@ -371,8 +373,14 @@ class Handler(object):
 | 
				
			|||||||
            return
 | 
					            return
 | 
				
			||||||
        url = dlg.url.GetValue()
 | 
					        url = dlg.url.GetValue()
 | 
				
			||||||
        bufftype = dlg.get_action()
 | 
					        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":
 | 
					        if bufftype == "local":
 | 
				
			||||||
            title = _(f"Local timeline for {url}")
 | 
					            title = _(f"Local timeline for {url.replace('https://', '')}")
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            title = _(f"Federated timeline for {url}")
 | 
					            title = _(f"Federated timeline for {url}")
 | 
				
			||||||
            bufftype = "public"
 | 
					            bufftype = "public"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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)
 | 
					    dlg = wx.MessageDialog(None, _("Sorry, you can't update while running {} from source.").format(application.name), _("Error"), wx.OK)
 | 
				
			||||||
    return dlg.ShowModal()
 | 
					    return dlg.ShowModal()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def invalid_instance():
 | 
				
			||||||
 | 
					    return wx.MessageDialog(None, _("the provided instance is invalid. Please try again."), _("Invalid instance"), wx.ICON_ERROR).ShowModal()
 | 
				
			||||||
		Reference in New Issue
	
	Block a user