Merge pull request #162 from zambonin/master

Force quit and subscription page fixes. #156 #161 #163
This commit is contained in:
Michael Lazar
2015-10-16 17:58:38 -07:00
4 changed files with 18 additions and 5 deletions

View File

@@ -67,7 +67,7 @@ Basic Commands
:``r`` or ``F5``: Refresh page content
:``u``: Log in or switch accounts
:``?``: Show the help screen
:``q``: Quit
:``q``/``Q``: Quit/Force quit
----------------------
Authenticated Commands

View File

@@ -29,7 +29,7 @@ Basic Commands
`r` or `F5` : Refresh page content
`u` : Log in or switch accounts
`?` : Show the help screen
`q` : Quit
`q/Q` : Quit/Force quit
Authenticated Commands
`a/z` : Upvote/downvote

View File

@@ -275,6 +275,10 @@ class BasePage(object):
elif ch != 'n':
curses.flash()
@BaseController.register('Q')
def force_exit(self):
sys.exit()
@BaseController.register('?')
def help(self):
show_help(self._content_window)
@@ -439,6 +443,10 @@ class BasePage(object):
Checks the inbox for unread messages and displays a notification.
"""
if not self.reddit.is_oauth_session():
show_notification(self.stdscr, ['Not logged in'])
return
inbox = len(list(self.reddit.get_unread(limit=1)))
try:
if inbox > 0:

View File

@@ -34,11 +34,16 @@ class SubscriptionPage(BasePage):
self.controller.trigger(cmd)
@SubscriptionController.register(curses.KEY_F5, 'r')
def refresh_content(self):
def refresh_content(self, order=None):
"Re-download all subscriptions and reset the page index"
self.content = SubscriptionContent.from_user(self.reddit, self.loader)
self.nav = Navigator(self.content.get)
if order:
# reddit.get_my_subreddits() does not support sorting by order
curses.flash()
else:
self.content = SubscriptionContent.from_user(self.reddit,
self.loader)
self.nav = Navigator(self.content.get)
@SubscriptionController.register(curses.KEY_ENTER, 10, curses.KEY_RIGHT)
def store_selected_subreddit(self):