reload functionality
This commit is contained in:
parent
edeeb793ff
commit
c5997da668
9
hn.py
9
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()
|
||||
|
Loading…
Reference in New Issue
Block a user