fix display of reposted posts

This commit is contained in:
Morgan McMillian 2021-01-01 15:25:18 -08:00
parent 04a6746bd7
commit fa6dd5126f

View file

@ -362,6 +362,11 @@ class PostItem(Gtk.ListBoxRow):
def __init__(self, post):
super(Gtk.ListBoxRow, self).__init__()
if 'repost_of' in post:
reposted_by = post.user
post = post.repost_of
else:
reposted_by = None
self.post = post
# Avatar
@ -433,6 +438,14 @@ class PostItem(Gtk.ListBoxRow):
photo = Gtk.Image.new_from_pixbuf(self.get_oembed_thumb(oembed))
self.c_box.pack_end(photo, False, False, 10)
if reposted_by is not None:
reposted_label_text = f'<span size="small"><i>reposted by @{reposted_by.username}</i></span>'
reposted_label = Gtk.Label(xalign=0)
reposted_label.set_margin_left(10)
reposted_label.set_margin_top(5)
reposted_label.set_markup(reposted_label_text)
self.c_box.pack_end(reposted_label, False, False, 0)
# footer container
self.f_box = Gtk.Box(orientation='horizontal')
self.f_box.pack_end(self.menu_button, False, False, 5)