reload functionality

This commit is contained in:
Felix Pankratz 2023-08-30 16:34:03 +02:00
parent edeeb793ff
commit c5997da668

9
hn.py
View File

@ -113,6 +113,8 @@ class Client:
else:
webbrowser.open(self.loadedstories[self.story_pos + self.cursor_pos].link)
self.loadedstories[self.story_pos + self.cursor_pos].read = True
elif c == ord('r'):
self.reload()
elif c == curses.KEY_RESIZE:
curses.resize_term(*self.screen.getmaxyx())
self.lines, self.cols = self.screen.getmaxyx()
@ -135,6 +137,13 @@ class Client:
import sys
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():
try:
client = Client()