reload functionality

master
Felix Pankratz 1 year ago
parent edeeb793ff
commit c5997da668

@ -113,6 +113,8 @@ class Client:
else: else:
webbrowser.open(self.loadedstories[self.story_pos + self.cursor_pos].link) webbrowser.open(self.loadedstories[self.story_pos + self.cursor_pos].link)
self.loadedstories[self.story_pos + self.cursor_pos].read = True self.loadedstories[self.story_pos + self.cursor_pos].read = True
elif c == ord('r'):
self.reload()
elif c == curses.KEY_RESIZE: elif c == curses.KEY_RESIZE:
curses.resize_term(*self.screen.getmaxyx()) curses.resize_term(*self.screen.getmaxyx())
self.lines, self.cols = self.screen.getmaxyx() self.lines, self.cols = self.screen.getmaxyx()
@ -135,6 +137,13 @@ class Client:
import sys import sys
sys.exit(0) sys.exit(0)
def reload(self):
self.topstories = api.get_topstories()
self.loadedstories = []
self.story_pos = 0
self.cursor_pos = 0
self.load_more_if_needed()
def main(): def main():
try: try:
client = Client() client = Client()

Loading…
Cancel
Save