fix bug when reloading and resizing
This commit is contained in:
parent
6ec69dc892
commit
42b1f50130
3
api.py
3
api.py
@ -9,6 +9,7 @@ class Story:
|
|||||||
author: str
|
author: str
|
||||||
votes: int
|
votes: int
|
||||||
comments: int
|
comments: int
|
||||||
|
read: bool
|
||||||
|
|
||||||
def get_topstories():
|
def get_topstories():
|
||||||
# Query Hacker News API for top stories and their titles/links
|
# 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['url'] if 'url' in s else 'No URL',
|
||||||
s['by'],
|
s['by'],
|
||||||
s['score'],
|
s['score'],
|
||||||
len(s['kids']) if 'kids' in s else 0)
|
len(s['kids']) if 'kids' in s else 0, False)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
ts = get_topstories()
|
ts = get_topstories()
|
||||||
|
4
hn.py
4
hn.py
@ -134,7 +134,7 @@ class Client:
|
|||||||
self.load_more_if_needed()
|
self.load_more_if_needed()
|
||||||
|
|
||||||
def load_more_if_needed(self):
|
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
|
# 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)
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ class Client:
|
|||||||
#self.loadedstories = []
|
#self.loadedstories = []
|
||||||
self.story_pos = 0
|
self.story_pos = 0
|
||||||
self.cursor_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():
|
def main():
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user