use cache when possible for tab switching

This commit is contained in:
Izalia Mae 2022-10-28 11:15:28 -04:00
parent 5f615c6e9a
commit 5b75a64e84

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)