Add option to display relative datetimes
This commit is contained in:
parent
deebdf7141
commit
f3b90c947e
4 changed files with 22 additions and 6 deletions
|
@ -417,4 +417,4 @@ def notifications(app, user, args):
|
|||
|
||||
def tui(app, user, args):
|
||||
from .tui.app import TUI
|
||||
TUI.create(app, user).run()
|
||||
TUI.create(app, user, args).run()
|
||||
|
|
|
@ -254,7 +254,13 @@ TUI_COMMANDS = [
|
|||
Command(
|
||||
name="tui",
|
||||
description="Launches the toot terminal user interface",
|
||||
arguments=[],
|
||||
arguments=[
|
||||
(["--relative-datetimes"], {
|
||||
"action": "store_true",
|
||||
"default": False,
|
||||
"help": "Show relative datetimes in status list.",
|
||||
}),
|
||||
],
|
||||
require_auth=True,
|
||||
),
|
||||
]
|
||||
|
|
|
@ -73,10 +73,10 @@ class TUI(urwid.Frame):
|
|||
"""Main TUI frame."""
|
||||
|
||||
@classmethod
|
||||
def create(cls, app, user):
|
||||
def create(cls, app, user, args):
|
||||
"""Factory method, sets up TUI and an event loop."""
|
||||
|
||||
tui = cls(app, user)
|
||||
tui = cls(app, user, args)
|
||||
loop = urwid.MainLoop(
|
||||
tui,
|
||||
palette=PALETTE,
|
||||
|
@ -87,9 +87,10 @@ class TUI(urwid.Frame):
|
|||
|
||||
return tui
|
||||
|
||||
def __init__(self, app, user):
|
||||
def __init__(self, app, user, args):
|
||||
self.app = app
|
||||
self.user = user
|
||||
self.args = args
|
||||
self.config = config.load_config()
|
||||
|
||||
self.loop = None # set in `create`
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import sys
|
||||
import urwid
|
||||
import webbrowser
|
||||
|
||||
|
@ -421,7 +422,15 @@ class StatusDetails(urwid.Pile):
|
|||
class StatusListItem(SelectableColumns):
|
||||
def __init__(self, status):
|
||||
edited = status.data["edited_at"]
|
||||
created_at = time_ago(status.created_at).ljust(3, " ")
|
||||
|
||||
# TODO: hacky implementation to avoid creating conflicts for existing
|
||||
# pull reuqests, refactor when merged.
|
||||
created_at = (
|
||||
time_ago(status.created_at).ljust(3, " ")
|
||||
if "--relative-datetimes" in sys.argv
|
||||
else status.created_at.strftime("%Y-%m-%d %H:%M")
|
||||
)
|
||||
|
||||
edited_flag = "*" if edited else " "
|
||||
favourited = ("yellow", "★") if status.original.favourited else " "
|
||||
reblogged = ("yellow", "♺") if status.original.reblogged else " "
|
||||
|
|
Loading…
Reference in a new issue