fix: fix duplicate icons
This commit is contained in:
16
src/main.py
16
src/main.py
@@ -69,9 +69,6 @@ class LemonadeWindow(Gtk.ApplicationWindow):
|
|||||||
def refresh(self, *args):
|
def refresh(self, *args):
|
||||||
self.communities = requests.get("https://lemmy.ml/api/v3/community/list?sort=Hot").json()
|
self.communities = requests.get("https://lemmy.ml/api/v3/community/list?sort=Hot").json()
|
||||||
for community in self.communities["communities"]:
|
for community in self.communities["communities"]:
|
||||||
if community["community"]["nfsw"] == True or community["community"]["hidden"] == True:
|
|
||||||
continue
|
|
||||||
|
|
||||||
box = Gtk.Box(
|
box = Gtk.Box(
|
||||||
orientation=Gtk.Orientation.HORIZONTAL,
|
orientation=Gtk.Orientation.HORIZONTAL,
|
||||||
margin_top = 20,
|
margin_top = 20,
|
||||||
@@ -86,19 +83,20 @@ class LemonadeWindow(Gtk.ApplicationWindow):
|
|||||||
|
|
||||||
if "icon" in community["community"]:
|
if "icon" in community["community"]:
|
||||||
try:
|
try:
|
||||||
urllib.request.urlretrieve(community["community"]["icon"], "tmp.png")
|
name = community["community"]["name"]
|
||||||
|
urllib.request.urlretrieve(community["community"]["icon"], f"{name}.png")
|
||||||
|
avatar.set_custom_image(Gdk.Texture.new_from_file(Gio.File.new_for_path(f"./{name}.png")))
|
||||||
except urllib.error.HTTPError as e:
|
except urllib.error.HTTPError as e:
|
||||||
print(e)
|
print(f"Error while downloading icon: {e}")
|
||||||
|
pass
|
||||||
avatar.set_custom_image(Gdk.Texture.new_from_file(Gio.File.new_for_path("./tmp.png")))
|
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not "description" in community["community"]:
|
if not "description" in community["community"]:
|
||||||
label.set_markup(f"""<big><b>{community["community"]["title"]}</b></big> <small>c/{community["community"]["name"]}</small>""")
|
label.set_markup(f"""<big><b>{community["community"]["title"]}</b></big> <small>!{community["community"]["name"]}@{community["community"]["actor_id"].split("/")[2]}</small>""")
|
||||||
else:
|
else:
|
||||||
split = community["community"]["description"].split("\n")[0]
|
split = community["community"]["description"].split("\n")[0]
|
||||||
label.set_markup(f"""<big><b>{community["community"]["title"]}</b></big> <small>c/{community["community"]["name"]}</small>
|
label.set_markup(f"""<big><b>{community["community"]["title"]}</b></big> <small>!{community["community"]["name"]}@{community["community"]["actor_id"].split("/")[2]}</small>
|
||||||
{split}""")
|
{split}""")
|
||||||
|
|
||||||
label.props.margin_start = 5
|
label.props.margin_start = 5
|
||||||
|
Reference in New Issue
Block a user