Extract refresh timeline code
This commit is contained in:
parent
9999d975b4
commit
71a2520198
1 changed files with 28 additions and 22 deletions
|
@ -493,7 +493,8 @@ class TUI(urwid.Frame):
|
||||||
def goto_public_timeline(self, local):
|
def goto_public_timeline(self, local):
|
||||||
self.timeline_generator = api.public_timeline_generator(
|
self.timeline_generator = api.public_timeline_generator(
|
||||||
self.app, self.user, local=local, limit=40)
|
self.app, self.user, local=local, limit=40)
|
||||||
promise = self.async_load_timeline(is_initial=True, timeline_name="local public" if local else "global public")
|
timeline_name = "local public" if local else "global public"
|
||||||
|
promise = self.async_load_timeline(is_initial=True, timeline_name=timeline_name)
|
||||||
promise.add_done_callback(lambda *args: self.close_overlay())
|
promise.add_done_callback(lambda *args: self.close_overlay())
|
||||||
|
|
||||||
def goto_bookmarks(self):
|
def goto_bookmarks(self):
|
||||||
|
@ -715,6 +716,31 @@ class TUI(urwid.Frame):
|
||||||
if self.timeline:
|
if self.timeline:
|
||||||
self.timeline.refresh_status_details()
|
self.timeline.refresh_status_details()
|
||||||
|
|
||||||
|
def refresh_timeline(self):
|
||||||
|
# No point in refreshing the bookmarks timeline
|
||||||
|
if not self.timeline or self.timeline.name == 'bookmarks':
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.timeline.name.startswith("#"):
|
||||||
|
self.timeline_generator = api.tag_timeline_generator(
|
||||||
|
self.app, self.user, self.timeline.name[1:], limit=40)
|
||||||
|
else:
|
||||||
|
if self.timeline.name.endswith("public"):
|
||||||
|
self.timeline_generator = api.public_timeline_generator(
|
||||||
|
self.app, self.user, local=self.timeline.name.startswith("local"), limit=40)
|
||||||
|
elif self.timeline.name == "notifications":
|
||||||
|
self.timeline_generator = api.notification_timeline_generator(
|
||||||
|
self.app, self.user, limit=40)
|
||||||
|
elif self.timeline.name == "conversations":
|
||||||
|
self.timeline_generator = api.conversation_timeline_generator(
|
||||||
|
self.app, self.user, limit=40)
|
||||||
|
else:
|
||||||
|
# default to home timeline
|
||||||
|
self.timeline_generator = api.home_timeline_generator(
|
||||||
|
self.app, self.user, limit=40)
|
||||||
|
|
||||||
|
self.async_load_timeline(is_initial=True, timeline_name=self.timeline.name)
|
||||||
|
|
||||||
# --- Keys -----------------------------------------------------------------
|
# --- Keys -----------------------------------------------------------------
|
||||||
|
|
||||||
def unhandled_input(self, key):
|
def unhandled_input(self, key):
|
||||||
|
@ -733,27 +759,7 @@ class TUI(urwid.Frame):
|
||||||
|
|
||||||
elif key == ',':
|
elif key == ',':
|
||||||
if not self.overlay:
|
if not self.overlay:
|
||||||
if self.timeline.name == 'bookmarks':
|
self.refresh_timeline()
|
||||||
return # no point in refreshing the bookmarks timeline
|
|
||||||
if self.timeline.name.startswith("#"):
|
|
||||||
self.timeline_generator = api.tag_timeline_generator(
|
|
||||||
self.app, self.user, self.timeline.name[1:], limit=40)
|
|
||||||
else:
|
|
||||||
if self.timeline.name.endswith('public'):
|
|
||||||
self.timeline_generator = api.public_timeline_generator(
|
|
||||||
self.app, self.user, local=self.timeline.name.startswith('local'), limit=40)
|
|
||||||
elif self.timeline.name == 'notifications':
|
|
||||||
self.timeline_generator = api.notification_timeline_generator(
|
|
||||||
self.app, self.user, limit=40)
|
|
||||||
elif self.timeline.name == 'conversations':
|
|
||||||
self.timeline_generator = api.conversation_timeline_generator(
|
|
||||||
self.app, self.user, limit=40)
|
|
||||||
else:
|
|
||||||
# default to home timeline
|
|
||||||
self.timeline_generator = api.home_timeline_generator(
|
|
||||||
self.app, self.user, limit=40)
|
|
||||||
|
|
||||||
self.async_load_timeline(is_initial=True, timeline_name=self.timeline.name)
|
|
||||||
|
|
||||||
elif key == 'esc':
|
elif key == 'esc':
|
||||||
if self.overlay:
|
if self.overlay:
|
||||||
|
|
Loading…
Reference in a new issue