Don't break if poll doesn't have an expiry date

This commit is contained in:
Ivan Habunek 2022-11-12 07:55:25 +01:00
parent 24cfa48dea
commit e318581dd1
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
1 changed files with 8 additions and 6 deletions

View File

@ -334,13 +334,15 @@ class StatusDetails(urwid.Pile):
yield urwid.Text(option["title"])
yield urwid.ProgressBar("", "poll_bar", perc)
if poll["expired"]:
status = "Closed"
else:
expires_at = parse_datetime(poll["expires_at"]).strftime("%Y-%m-%d %H:%M")
status = "Closes on {}".format(expires_at)
status = "Poll · {} votes".format(poll["votes_count"])
if poll["expired"]:
status += " · Closed"
if poll["expires_at"]:
expires_at = parse_datetime(poll["expires_at"]).strftime("%Y-%m-%d %H:%M")
status += " · Closes on {}".format(expires_at)
status = "Poll · {} votes · {}".format(poll["votes_count"], status)
yield urwid.Text(("gray", status))