1
0
mirror of https://github.com/ihabunek/toot synced 2024-12-23 07:27:12 +01:00

Fix version check in case of an empty string

Some mastodon implementations (GoToSocial) will return `version: ""`, in
which case checking for the major version won't work.

This is why an extra check has to be added, and default to 0 as the
"major" version.
This commit is contained in:
Luca Matei Pintilie 2024-04-06 12:57:39 +02:00 committed by Ivan Habunek
parent bf12dbff70
commit 1d48e64853
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D

View File

@ -327,8 +327,10 @@ class TUI(urwid.Frame):
# get the major version number of the server
# this works for Mastodon and Pleroma version strings
# Mastodon versions < 4 do not have translation service
# If the version is missing, assume 0 as a fallback
# Revisit this logic if Pleroma implements translation
ch = instance["version"][0]
version = instance["version"]
ch = "0" if not version else version[0]
self.can_translate = int(ch) > 3 if ch.isnumeric() else False
return self.run_in_thread(_load_instance, done_callback=_done)