mirror of
https://github.com/ihabunek/toot
synced 2025-01-11 09:03:57 +01:00
tui: add --always-show-sensitive option
When enabled, this option expands toots with content warnings automatically, instead of requiring the user to press 'S'.
This commit is contained in:
parent
f394d78c1e
commit
1ed129f5dd
@ -29,11 +29,17 @@ COLOR_OPTIONS = ", ".join(TUI_COLORS.keys())
|
|||||||
type=click.Choice(VISIBILITY_CHOICES),
|
type=click.Choice(VISIBILITY_CHOICES),
|
||||||
help="Default visibility when posting new toots; overrides the server-side preference"
|
help="Default visibility when posting new toots; overrides the server-side preference"
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
"-S", "--always-show-sensitive",
|
||||||
|
is_flag=True,
|
||||||
|
help="Expand toots with content warnings automatically"
|
||||||
|
)
|
||||||
@pass_context
|
@pass_context
|
||||||
def tui(
|
def tui(
|
||||||
ctx: Context,
|
ctx: Context,
|
||||||
colors: Optional[int],
|
colors: Optional[int],
|
||||||
media_viewer: Optional[str],
|
media_viewer: Optional[str],
|
||||||
|
always_show_sensitive: bool,
|
||||||
relative_datetimes: bool,
|
relative_datetimes: bool,
|
||||||
default_visibility: Optional[str]
|
default_visibility: Optional[str]
|
||||||
):
|
):
|
||||||
@ -45,7 +51,8 @@ def tui(
|
|||||||
colors=colors,
|
colors=colors,
|
||||||
media_viewer=media_viewer,
|
media_viewer=media_viewer,
|
||||||
relative_datetimes=relative_datetimes,
|
relative_datetimes=relative_datetimes,
|
||||||
default_visibility=default_visibility
|
default_visibility=default_visibility,
|
||||||
|
always_show_sensitive=always_show_sensitive,
|
||||||
)
|
)
|
||||||
tui = TUI.create(ctx.app, ctx.user, options)
|
tui = TUI.create(ctx.app, ctx.user, options)
|
||||||
tui.run()
|
tui.run()
|
||||||
|
@ -30,6 +30,7 @@ DEFAULT_MAX_TOOT_CHARS = 500
|
|||||||
class TuiOptions(NamedTuple):
|
class TuiOptions(NamedTuple):
|
||||||
colors: int
|
colors: int
|
||||||
media_viewer: Optional[str]
|
media_viewer: Optional[str]
|
||||||
|
always_show_sensitive: bool
|
||||||
relative_datetimes: bool
|
relative_datetimes: bool
|
||||||
default_visibility: Optional[bool]
|
default_visibility: Optional[bool]
|
||||||
|
|
||||||
|
@ -313,6 +313,7 @@ class StatusDetails(urwid.Pile):
|
|||||||
def __init__(self, timeline: Timeline, status: Optional[Status]):
|
def __init__(self, timeline: Timeline, status: Optional[Status]):
|
||||||
self.status = status
|
self.status = status
|
||||||
self.followed_accounts = timeline.tui.followed_accounts
|
self.followed_accounts = timeline.tui.followed_accounts
|
||||||
|
self.options = timeline.tui.options
|
||||||
|
|
||||||
reblogged_by = status.author if status and status.reblog else None
|
reblogged_by = status.author if status and status.reblog else None
|
||||||
widget_list = list(self.content_generator(status.original, reblogged_by)
|
widget_list = list(self.content_generator(status.original, reblogged_by)
|
||||||
@ -337,7 +338,7 @@ class StatusDetails(urwid.Pile):
|
|||||||
yield ("pack", urwid.Divider())
|
yield ("pack", urwid.Divider())
|
||||||
|
|
||||||
# Show content warning
|
# Show content warning
|
||||||
if status.data["spoiler_text"] and not status.show_sensitive:
|
if status.data["spoiler_text"] and not status.show_sensitive and not self.options.always_show_sensitive:
|
||||||
yield ("pack", urwid.Text(("content_warning", "Marked as sensitive. Press S to view.")))
|
yield ("pack", urwid.Text(("content_warning", "Marked as sensitive. Press S to view.")))
|
||||||
else:
|
else:
|
||||||
if status.data["spoiler_text"]:
|
if status.data["spoiler_text"]:
|
||||||
|
Loading…
Reference in New Issue
Block a user