fix: wipe cache when removing row

This commit is contained in:
aclist 2026-04-25 19:17:32 +09:00
parent ed508c6764
commit 61735d20cf
6 changed files with 20 additions and 13 deletions

View File

@ -536,10 +536,15 @@ class Controller(GObject.GObject):
def has_server_model(self) -> bool:
treeview = self.get_active_treeview()
return treeview.get_model() is not None
proxy_man = treeview.get_proxy_man()
control = proxy_man.get_control()
if control is None:
return False
if len(control) < 1:
return False
return True
def _on_check_toggled(self, emitter: Emitter, label: str, state: bool) -> None:
print("DEBUG: check toggled, refiltering")
filter_man = self.get_filter_man()
filter_man.set_filter(label, state)
@ -547,7 +552,6 @@ class Controller(GObject.GObject):
ServerModelManager(self, self.get_active_treeview()).refilter(mode)
def _on_map_selection_changed(self, emitter: Emitter, selection: str) -> None:
print("DEBUG: map sel changed, refiltering")
smm = ServerModelManager(self, self.get_active_treeview())
smm.refilter(FilterMode.MAP)
@ -569,6 +573,12 @@ class Controller(GObject.GObject):
def get_menu(self) -> "MenuTreeView":
return self.mediator.menu
def has_favorites(self) -> bool:
favs = self.config_man.get_favorites()
if len(favs) < 1:
return False
return True
def is_in_favs(self) -> bool:
return self.config_man.is_in_favs()

View File

@ -143,5 +143,4 @@ def main() -> None:
use_miles,
)
print("All OK. Loading UI...")
logger.critical("e")
App(prefs)

View File

@ -51,6 +51,7 @@ class ProxyModelManager:
for record in self.control_model:
if row[7] == record[7] and row[8] == record[8]:
self.control_model.remove(record)
self.wipe_cache()
self.filter(FilterMode.INITIAL, skip_cache=True)
def update_playercount(self, playercount: "NewPlayerCount") -> None:
@ -214,6 +215,7 @@ class ProxyModelManager:
) -> None:
self.filter_cache[filters] = (model, rows)
@deprecated("legacy logic")
def resync_model(self, addr: str, qport: int) -> None:
"""
Handle in-situ updates to model during

View File

@ -54,15 +54,9 @@ class ServerModelManager:
self.preserve_on_fail = False
self.jobs = 1
# NOTE: store filter man for access inside thread
self.proxy_man = tv.get_proxy_man()
self.thread_man = ThreadingManager(self.controller)
# TODO: if first iteration, clear filter man control model
# literal first load: iteration 1
# refresh: should be functionally identical to iteration 1
# filter: iteration N+1
def load(self) -> None:
"""
There may be cases where you want to instantiate this class without dumping servers,
@ -327,8 +321,8 @@ class ServerModelManager:
maps = self._get_new_maps()
filter_man.set_unique_maps(maps)
self.emitter.emit("servers_loaded_init")
self.first_iteration = False
self.emitter.emit("servers_loaded_init")
self.emitter.emit("saved_servers_changed")
def _update_maps(self) -> None:

View File

@ -105,8 +105,9 @@ class RefreshButton(IconTextButton):
def _on_refresh_clicked(self, button: Self) -> None:
"""Spawned in a thread"""
self.loading = True
self.controller.refresh_tree()
if self.controller.has_favorites():
self.loading = True
self.controller.refresh_tree()
# TODO: get server tab enum
# if LAN tab, reload existing entries in place

View File

@ -67,6 +67,7 @@ class Statusbar(Gtk.Grid):
self.controller.populate_log()
def _on_log_page_loaded(self, emitter: "Emitter") -> None:
# FIXME: fails if button was not previously drawn
self.alert_button.hide()
def _on_mod_page_loaded(self, emitter: "Emitter") -> None: