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