clan_vm_manager: Fix incorrect detection of vm already in list

This commit is contained in:
Luis Hebendanz 2024-03-05 23:23:21 +07:00
parent 1986ecc564
commit 0840fffe26
2 changed files with 6 additions and 4 deletions

View File

@ -3,6 +3,7 @@ from pathlib import Path
from typing import Any
import gi
from clan_cli.clan_uri import ClanURI
from clan_cli.history.add import HistoryEntry
from clan_vm_manager import assets
@ -87,11 +88,11 @@ class ClanStore:
def remove(self, vm: VMObject) -> None:
del self.clan_store[vm.data.flake.flake_url][vm.data.flake.flake_attr]
def get_vm(self, flake_url: str, flake_attr: str) -> None | VMObject:
clan = self.clan_store.get(flake_url)
def get_vm(self, uri: ClanURI) -> None | VMObject:
clan = self.clan_store.get(uri.get_internal())
if clan is None:
return None
return clan.get(flake_attr, None)
return clan.get(uri.params.flake_attr, None)
def get_running_vms(self) -> list[VMObject]:
return [

View File

@ -191,8 +191,9 @@ class ClanList(Gtk.Box):
row.set_subtitle(item.url.get_internal())
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 item.url.get_internal() in ClanStore.use().clan_store:
if vm is not None:
sub = row.get_subtitle()
row.set_subtitle(
sub + "\nClan already exists. Joining again will update it"