From c5997da668c9f14236bd2de2033023caf8faee1c Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Wed, 30 Aug 2023 16:34:03 +0200 Subject: [PATCH] reload functionality --- hn.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hn.py b/hn.py index ebea9fc..059b398 100755 --- a/hn.py +++ b/hn.py @@ -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()