From 42b1f5013095a90362d825bcd30118e4bf5dc558 Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Wed, 30 Aug 2023 19:58:47 +0200 Subject: [PATCH] fix bug when reloading and resizing --- api.py | 3 ++- hn.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api.py b/api.py index 57b1be8..a3b5273 100644 --- a/api.py +++ b/api.py @@ -9,6 +9,7 @@ class Story: author: str votes: int comments: int + read: bool def get_topstories(): # Query Hacker News API for top stories and their titles/links @@ -27,7 +28,7 @@ def get_story(story_id): s['url'] if 'url' in s else 'No URL', s['by'], s['score'], - len(s['kids']) if 'kids' in s else 0) + len(s['kids']) if 'kids' in s else 0, False) def main(): ts = get_topstories() diff --git a/hn.py b/hn.py index 9c151eb..3b911dc 100755 --- a/hn.py +++ b/hn.py @@ -134,9 +134,9 @@ class Client: self.load_more_if_needed() def load_more_if_needed(self): - # if len(self.loadedstories) < self.story_pos + self.stories_in_a_site: + if len(self.loadedstories) < self.story_pos + self.stories_in_a_site: # load more - self.load_stories(self.story_pos, self.story_pos + self.stories_in_a_site) + self.load_stories(self.story_pos, self.story_pos + self.stories_in_a_site) def run(self): self.load_stories(0, self.stories_in_a_site) @@ -156,7 +156,7 @@ class Client: #self.loadedstories = [] self.story_pos = 0 self.cursor_pos = 0 - self.load_more_if_needed() + self.load_stories(self.cursor_pos, self.cursor_pos + self.stories_in_a_site) def main(): try: