Compare commits

...

2 commits

Author SHA1 Message Date
Izalia Mae 5b75a64e84 use cache when possible for tab switching 2022-10-28 11:15:28 -04:00
Izalia Mae 5f615c6e9a handle dns errors on new url 2022-10-28 11:15:07 -04:00
2 changed files with 18 additions and 7 deletions

View file

@ -2,7 +2,7 @@ import cairo
import threading
from bs4 import BeautifulSoup
from dns.resolver import NXDOMAIN
from dns.resolver import NXDOMAIN, NoAnswer
from izzylib.exceptions import DNSResolverError
from izzylib.misc import class_name
from izzylib.url import Address
@ -519,7 +519,7 @@ class WebTab(BuilderBase, Gtk.Box):
url = Url(f'{proto}://{full_url}')
except ValueError:
return self.window.notification(f'Not a valid url: {full_url}')
return run_in_gui_thread(self.window.notification, f'Not a valid url: {full_url}')
else:
url = Url(full_url)
@ -555,8 +555,8 @@ class WebTab(BuilderBase, Gtk.Box):
port = 80 if url.port == 443 else url.port
)
except NXDOMAIN:
pass
except (NXDOMAIN, NoAnswer):
return run_in_gui_thread(self.window.notification, f'Failed to resolve domain: {url.domain}')
if not address:
search = s.get_search(keyword, default=True)

View file

@ -1,5 +1,6 @@
import json, sys, threading, time
from izzylib.misc import Boolean
from izzylib_sql import Row
from .status_bar import StatusBar
@ -423,9 +424,19 @@ class Window(BuilderBase, Gtk.ApplicationWindow):
def handle_page_switch(self, notebook, tab, pagenum):
with self.app.db.session as s:
if tab._data.state and not self.startup and s.get_config('load_switch'):
tab.page_action('refresh')
if load_switch_cache := self.db.cache['config'].get('load_switch'):
load_switch = Boolean(load_switch_cache['value'])
else:
with self.db.session() as s:
load_switch = s.get_config('load_switch')
if load_switch and tab._data.state and not self.startup:
tab.page_action('refresh')
# with self.app.db.session as s:
# if tab._data.state and not self.startup and s.get_config('load_switch'):
# tab.page_action('refresh')
if tab.id in self.taborder:
self.taborder.remove(tab.id)