clan_vm_manager: Fix join list not rerendering correctly when updating clan_store
This commit is contained in:
parent
0840fffe26
commit
cd5afa1329
|
@ -69,10 +69,10 @@ class MainApplication(Adw.Application):
|
|||
# convert GVariantDict -> GVariant -> dict
|
||||
options = options.end().unpack()
|
||||
|
||||
if "debug" in options:
|
||||
if "debug" in options and self.window is None:
|
||||
setup_logging(logging.DEBUG, root_log_name=__name__.split(".")[0])
|
||||
setup_logging(logging.DEBUG, root_log_name="clan_cli")
|
||||
else:
|
||||
elif self.window is None:
|
||||
setup_logging(logging.INFO, root_log_name=__name__.split(".")[0])
|
||||
log.debug("Debug logging enabled")
|
||||
|
||||
|
@ -81,7 +81,6 @@ class MainApplication(Adw.Application):
|
|||
self.activate()
|
||||
|
||||
if len(args) > 1:
|
||||
log.debug(f"Join request: {args[1]}")
|
||||
uri = args[1]
|
||||
self.emit("join_request", uri)
|
||||
return 0
|
||||
|
|
|
@ -166,7 +166,6 @@ class GKVStore(GObject.GObject, Gio.ListModel, Generic[K, V]):
|
|||
# O(1) operation if the key does not exist, O(n) if it does
|
||||
def __setitem__(self, key: K, value: V) -> None:
|
||||
# If the key already exists, remove it O(n)
|
||||
# TODO: We have to check if updating an existing key is working correctly
|
||||
if key in self._items:
|
||||
log.warning("Updating an existing key in GKVStore is O(n)")
|
||||
position = self.keys().index(key)
|
||||
|
|
|
@ -71,6 +71,18 @@ class JoinList:
|
|||
|
||||
def on_clan_store_items_changed(
|
||||
self, source: Any, position: int, removed: int, added: int
|
||||
) -> None:
|
||||
if added > 0:
|
||||
# Rerendering the join list every time an item changes in the vmstore
|
||||
ClanStore.use().clan_store.values()[position].connect(
|
||||
"items-changed", self.on_vm_store_items_changed
|
||||
)
|
||||
self.list_store.items_changed(
|
||||
0, self.list_store.get_n_items(), self.list_store.get_n_items()
|
||||
)
|
||||
|
||||
def on_vm_store_items_changed(
|
||||
self, source: Any, position: int, removed: int, added: int
|
||||
) -> None:
|
||||
self.list_store.items_changed(
|
||||
0, self.list_store.get_n_items(), self.list_store.get_n_items()
|
||||
|
|
|
@ -192,6 +192,7 @@ class ClanList(Gtk.Box):
|
|||
row.add_css_class("trust")
|
||||
|
||||
vm = ClanStore.use().get_vm(item.url)
|
||||
|
||||
# Can't do this here because clan store is empty at this point
|
||||
if vm is not None:
|
||||
sub = row.get_subtitle()
|
||||
|
|
Loading…
Reference in New Issue
Block a user