clan_vm_manager: Fix join list not rerendering correctly when updating clan_store
This commit is contained in:
@@ -69,10 +69,10 @@ class MainApplication(Adw.Application):
|
|||||||
# convert GVariantDict -> GVariant -> dict
|
# convert GVariantDict -> GVariant -> dict
|
||||||
options = options.end().unpack()
|
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=__name__.split(".")[0])
|
||||||
setup_logging(logging.DEBUG, root_log_name="clan_cli")
|
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])
|
setup_logging(logging.INFO, root_log_name=__name__.split(".")[0])
|
||||||
log.debug("Debug logging enabled")
|
log.debug("Debug logging enabled")
|
||||||
|
|
||||||
@@ -81,7 +81,6 @@ class MainApplication(Adw.Application):
|
|||||||
self.activate()
|
self.activate()
|
||||||
|
|
||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
log.debug(f"Join request: {args[1]}")
|
|
||||||
uri = args[1]
|
uri = args[1]
|
||||||
self.emit("join_request", uri)
|
self.emit("join_request", uri)
|
||||||
return 0
|
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
|
# O(1) operation if the key does not exist, O(n) if it does
|
||||||
def __setitem__(self, key: K, value: V) -> None:
|
def __setitem__(self, key: K, value: V) -> None:
|
||||||
# If the key already exists, remove it O(n)
|
# 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:
|
if key in self._items:
|
||||||
log.warning("Updating an existing key in GKVStore is O(n)")
|
log.warning("Updating an existing key in GKVStore is O(n)")
|
||||||
position = self.keys().index(key)
|
position = self.keys().index(key)
|
||||||
|
|||||||
@@ -71,6 +71,18 @@ class JoinList:
|
|||||||
|
|
||||||
def on_clan_store_items_changed(
|
def on_clan_store_items_changed(
|
||||||
self, source: Any, position: int, removed: int, added: int
|
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:
|
) -> None:
|
||||||
self.list_store.items_changed(
|
self.list_store.items_changed(
|
||||||
0, self.list_store.get_n_items(), self.list_store.get_n_items()
|
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")
|
row.add_css_class("trust")
|
||||||
|
|
||||||
vm = ClanStore.use().get_vm(item.url)
|
vm = ClanStore.use().get_vm(item.url)
|
||||||
|
|
||||||
# Can't do this here because clan store is empty at this point
|
# Can't do this here because clan store is empty at this point
|
||||||
if vm is not None:
|
if vm is not None:
|
||||||
sub = row.get_subtitle()
|
sub = row.get_subtitle()
|
||||||
|
|||||||
Reference in New Issue
Block a user