Extract code for getting default visibility
This commit is contained in:
parent
08a28bfb26
commit
e07be634f6
3 changed files with 11 additions and 6 deletions
|
@ -15,6 +15,10 @@ from toot.output import print_out, print_err
|
|||
VISIBILITY_CHOICES = ['public', 'unlisted', 'private', 'direct']
|
||||
|
||||
|
||||
def get_default_visibility():
|
||||
return os.getenv("TOOT_VISIBILITY", "public")
|
||||
|
||||
|
||||
def language(value):
|
||||
"""Validates the language parameter"""
|
||||
if len(value) != 2:
|
||||
|
@ -348,7 +352,7 @@ POST_COMMANDS = [
|
|||
}),
|
||||
(["-v", "--visibility"], {
|
||||
"type": visibility,
|
||||
"default": os.getenv("TOOT_VISIBILITY", "public"),
|
||||
"default": get_default_visibility(),
|
||||
"help": 'post visibility, one of: %s' % ", ".join(VISIBILITY_CHOICES),
|
||||
}),
|
||||
(["-s", "--sensitive"], {
|
||||
|
@ -437,7 +441,7 @@ STATUS_COMMANDS = [
|
|||
arguments=[status_id_arg,
|
||||
(["-v", "--visibility"], {
|
||||
"type": visibility,
|
||||
"default": os.getenv("TOOT_VISIBILITY", "public"),
|
||||
"default": get_default_visibility(),
|
||||
"help": 'boost visibility, one of: %s' % ", ".join(VISIBILITY_CHOICES),
|
||||
})],
|
||||
require_auth=True,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import logging
|
||||
import urwid
|
||||
import os
|
||||
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from toot import api, config, __version__
|
||||
from toot.console import get_default_visibility
|
||||
|
||||
from .compose import StatusComposer
|
||||
from .constants import PALETTE
|
||||
|
@ -495,7 +495,7 @@ class TUI(urwid.Frame):
|
|||
def async_toggle_reblog(self, timeline, status):
|
||||
def _reblog():
|
||||
logger.info("Reblogging {}".format(status))
|
||||
api.reblog(self.app, self.user, status.id, visibility=os.getenv("TOOT_VISIBILITY", "public"))
|
||||
api.reblog(self.app, self.user, status.id, visibility=get_default_visibility())
|
||||
|
||||
def _unreblog():
|
||||
logger.info("Unreblogging {}".format(status))
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import urwid
|
||||
import logging
|
||||
import os
|
||||
|
||||
from toot.console import get_default_visibility
|
||||
|
||||
from .constants import VISIBILITY_OPTIONS
|
||||
from .widgets import Button, EditBox
|
||||
|
@ -32,7 +33,7 @@ class StatusComposer(urwid.Frame):
|
|||
self.cw_remove_button = Button("Remove content warning",
|
||||
on_press=self.remove_content_warning)
|
||||
|
||||
self.visibility = os.getenv("TOOT_VISIBILITY", "public")
|
||||
self.visibility = get_default_visibility()
|
||||
self.visibility_button = Button("Visibility: {}".format(self.visibility),
|
||||
on_press=self.choose_visibility)
|
||||
|
||||
|
|
Loading…
Reference in a new issue