Save the correct link in the history

This commit is contained in:
codesoap
2018-08-25 21:30:08 +02:00
parent b8a5d28aa7
commit 5fcd7e517a
2 changed files with 13 additions and 10 deletions

View File

@@ -147,8 +147,9 @@ class SubmissionPage(Page):
data = self.get_selected_item() data = self.get_selected_item()
if data['type'] == 'Submission': if data['type'] == 'Submission':
self.prompt_and_open_link(data) opened_link = self.prompt_and_open_link(data)
self.config.history.add(data['url_full']) if opened_link is not None:
self.config.history.add(opened_link)
elif data['type'] == 'Comment' and data['permalink']: elif data['type'] == 'Comment' and data['permalink']:
self.prompt_and_open_link(data) self.prompt_and_open_link(data)
else: else:
@@ -159,11 +160,14 @@ class SubmissionPage(Page):
if data['html']: if data['html']:
links += self.get_links_in_html(data['html']) links += self.get_links_in_html(data['html'])
if len(links) > 1: if len(links) > 1:
self.term.prompt_user_and_open_selected_link(links) link = self.term.prompt_user_to_select_link(links)
elif 'url_full' in data and data['url_full']: elif 'url_full' in data and data['url_full']:
self.term.open_link(data['url_full']) link = data['url_full']
else: else:
self.term.open_link(data['permalink']) link = data['permalink']
if link is not None:
self.term.open_link(link)
return link
def get_links_in_html(self, html): def get_links_in_html(self, html):
links = [] links = []

View File

@@ -354,7 +354,7 @@ class Terminal(object):
return ch return ch
def prompt_user_and_open_selected_link(self, links): def prompt_user_to_select_link(self, links):
link_pages = self.get_link_pages(links) link_pages = self.get_link_pages(links)
for link_page in link_pages: for link_page in link_pages:
text = self.get_link_page_text(link_page) text = self.get_link_page_text(link_page)
@@ -364,13 +364,12 @@ class Terminal(object):
try: try:
choice = int(chr(self.show_notification(text))) choice = int(chr(self.show_notification(text)))
except ValueError: except ValueError:
return return None
if link_page is not link_pages[-1] and choice == 9: if link_page is not link_pages[-1] and choice == 9:
continue continue
elif choice == 0 or choice > len(link_page): elif choice == 0 or choice > len(link_page):
return return None
self.open_link(link_page[choice - 1]['href']) return link_page[choice - 1]['href']
return
def get_link_pages(self, links): def get_link_pages(self, links):
link_pages = [] link_pages = []