Add bubble timeline
This commit is contained in:
parent
d7da2de99a
commit
7b55fe7b4c
5 changed files with 32 additions and 5 deletions
|
@ -350,6 +350,12 @@ def public_timeline_generator(app, user, local=False, limit=20):
|
|||
return _timeline_generator(app, user, path, params)
|
||||
|
||||
|
||||
def bubble_timeline_generator(app, user, public=False, limit=20):
|
||||
path = "/api/v1/timelines/bubble"
|
||||
params = {"limit": limit}
|
||||
return _timeline_generator(app, user, path, params)
|
||||
|
||||
|
||||
def tag_timeline_generator(app, user, hashtag, local=False, limit=20):
|
||||
path = f"/api/v1/timelines/tag/{quote(hashtag)}"
|
||||
params = {'local': str_bool(local), 'limit': limit}
|
||||
|
|
|
@ -22,15 +22,18 @@ from witchie.utils.datetime import parse_datetime
|
|||
|
||||
def get_timeline_generator(app, user, args):
|
||||
if len([arg for arg in [args.tag, args.list, args.public, args.account] if arg]) > 1:
|
||||
raise ConsoleError("Only one of --public, --tag, --account, or --list can be used at one time.")
|
||||
raise ConsoleError("Only one of --public, --bubble, --tag, --account,"
|
||||
" or --list can be used at one time.")
|
||||
|
||||
if args.local and not (args.public or args.tag):
|
||||
if args.local and not (args.public or args.tag or args.bubble):
|
||||
raise ConsoleError("The --local option is only valid alongside --public or --tag.")
|
||||
|
||||
if args.instance and not (args.public or args.tag):
|
||||
if args.instance and not (args.public or args.tag or args.bubble):
|
||||
raise ConsoleError("The --instance option is only valid alongside --public or --tag.")
|
||||
|
||||
if args.public:
|
||||
if args.bubble:
|
||||
return api.bubble_timeline_generator(app, user, public=args.public, limit=args.count)
|
||||
elif args.public:
|
||||
if args.instance:
|
||||
return api.anon_public_timeline_generator(args.instance, local=args.local, limit=args.count)
|
||||
else:
|
||||
|
|
|
@ -259,6 +259,11 @@ common_timeline_args = [
|
|||
"default": False,
|
||||
"help": "show only statuses from local instance (public and tag timelines only)",
|
||||
}),
|
||||
(["-b", "--bubble"], {
|
||||
"action": "store_true",
|
||||
"default": False,
|
||||
"help": "show only statuses from bubble instances (set by instance admin)",
|
||||
}),
|
||||
(["-i", "--instance"], {
|
||||
"type": str,
|
||||
"help": "mastodon instance from which to read (public and tag timelines only)",
|
||||
|
|
|
@ -166,7 +166,7 @@ class TUI(urwid.Frame):
|
|||
urwid.Divider(),
|
||||
urwid.Text([
|
||||
"Maintained by ",
|
||||
("intro_smalltext", "@ihabunek"),
|
||||
("intro_smalltext", "~huyngo"),
|
||||
" and contributors"
|
||||
], align="center"),
|
||||
urwid.Divider(),
|
||||
|
@ -412,6 +412,8 @@ class TUI(urwid.Frame):
|
|||
menu = GotoMenu(user_timelines, user_lists)
|
||||
urwid.connect_signal(menu, "home_timeline",
|
||||
lambda x: self.goto_home_timeline())
|
||||
urwid.connect_signal(menu, "bubble_timeline",
|
||||
lambda x: self.goto_bubble_timeline())
|
||||
urwid.connect_signal(menu, "public_timeline",
|
||||
lambda x, local: self.goto_public_timeline(local))
|
||||
urwid.connect_signal(menu, "bookmark_timeline",
|
||||
|
@ -447,6 +449,12 @@ class TUI(urwid.Frame):
|
|||
promise = self.async_load_timeline(is_initial=True, timeline_name="home")
|
||||
promise.add_done_callback(lambda *args: self.close_overlay())
|
||||
|
||||
def goto_bubble_timeline(self):
|
||||
self.timeline_generator = api.bubble_timeline_generator(
|
||||
self.app, self.user, public=True, limit=40)
|
||||
promise = self.async_load_timeline(is_initial=True, timeline_name="home")
|
||||
promise.add_done_callback(lambda *args: self.close_overlay())
|
||||
|
||||
def goto_public_timeline(self, local):
|
||||
self.timeline_generator = api.public_timeline_generator(
|
||||
self.app, self.user, local=local, limit=40)
|
||||
|
|
|
@ -97,6 +97,7 @@ class StatusDeleteConfirmation(urwid.ListBox):
|
|||
class GotoMenu(urwid.ListBox):
|
||||
signals = [
|
||||
"home_timeline",
|
||||
"bubble_timeline",
|
||||
"public_timeline",
|
||||
"hashtag_timeline",
|
||||
"bookmark_timeline",
|
||||
|
@ -121,6 +122,9 @@ class GotoMenu(urwid.ListBox):
|
|||
def _home(button):
|
||||
self._emit("home_timeline")
|
||||
|
||||
def _bubble(button):
|
||||
self._emit("bubble_timeline")
|
||||
|
||||
def _local_public(button):
|
||||
self._emit("public_timeline", True)
|
||||
|
||||
|
@ -158,6 +162,7 @@ class GotoMenu(urwid.ListBox):
|
|||
return on_press
|
||||
|
||||
yield Button("Home timeline", on_press=_home)
|
||||
yield Button("Bubble timeline", on_press=_bubble)
|
||||
yield Button("Local public timeline", on_press=_local_public)
|
||||
yield Button("Global public timeline", on_press=_global_public)
|
||||
yield Button("Personal timeline", on_press=_personal)
|
||||
|
|
Loading…
Reference in a new issue