From a2e41ce51f58836a4f4ee0c25c68628012f2f431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Moreira?= Date: Thu, 28 May 2020 17:09:57 -0300 Subject: [PATCH] [fix][ui] not updating cached installed packages state after ignoring/reverting updates --- CHANGELOG.md | 2 +- bauh/gems/appimage/model.py | 4 ++++ bauh/gems/arch/model.py | 4 ++++ bauh/gems/flatpak/model.py | 4 ++++ bauh/gems/snap/model.py | 4 ++++ bauh/gems/web/model.py | 4 ++++ bauh/view/qt/thread.py | 2 +- bauh/view/qt/view_model.py | 4 ++++ bauh/view/qt/window.py | 6 ++++++ 9 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00b01aec..9d84646f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,7 +59,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - crashing while reading the installed packages when the internet is unstable - initialization dialog hangs when there is no task to wait for [#112](https://github.com/vinifmor/bauh/issues/112) -- not caching data of repository packages with unknown repository names +- not caching data of installed packages with no signatures and unknown repositories ## [0.9.3] 2020-05-12 ### Features diff --git a/bauh/gems/appimage/model.py b/bauh/gems/appimage/model.py index 948dcfaf..ee6b7b63 100644 --- a/bauh/gems/appimage/model.py +++ b/bauh/gems/appimage/model.py @@ -114,3 +114,7 @@ class AppImage(SoftwarePackage): def is_update_ignored(self) -> bool: return self.updates_ignored + + def __eq__(self, other): + if isinstance(other, AppImage): + return self.local_file_path == other.local_file_path diff --git a/bauh/gems/arch/model.py b/bauh/gems/arch/model.py index 5e4a941d..fc3d452e 100644 --- a/bauh/gems/arch/model.py +++ b/bauh/gems/arch/model.py @@ -145,3 +145,7 @@ class ArchPackage(SoftwarePackage): def __repr__(self): return '{} (name={}, command={}, icon_path={})'.format(self.__class__.__name__, self.name, self.command, self.icon_path) + + def __eq__(self, other): + if isinstance(other, ArchPackage): + return self.name == other.name and self.repository == other.repository diff --git a/bauh/gems/flatpak/model.py b/bauh/gems/flatpak/model.py index 182cb651..aa00e256 100644 --- a/bauh/gems/flatpak/model.py +++ b/bauh/gems/flatpak/model.py @@ -116,3 +116,7 @@ class FlatpakApplication(SoftwarePackage): def get_update_ignore_key(self) -> str: return '{}:{}:{}'.format(self.installation, self.id, self.branch) + + def __eq__(self, other): + if isinstance(other, FlatpakApplication): + return self.id == other.id and self.installation == other.installation and self.branch == other.branch diff --git a/bauh/gems/snap/model.py b/bauh/gems/snap/model.py index 668d4cb7..e3ec5984 100644 --- a/bauh/gems/snap/model.py +++ b/bauh/gems/snap/model.py @@ -78,3 +78,7 @@ class SnapApplication(SoftwarePackage): def supports_backup(self) -> bool: return True + + def __eq__(self, other): + if isinstance(other, SnapApplication): + return self.name == other.name diff --git a/bauh/gems/web/model.py b/bauh/gems/web/model.py index c0238600..7ac91ba8 100644 --- a/bauh/gems/web/model.py +++ b/bauh/gems/web/model.py @@ -148,3 +148,7 @@ class WebApplication(SoftwarePackage): def supports_backup(self) -> bool: return False + + def __eq__(self, other): + if isinstance(other, WebApplication): + return self.name == other.name and self.url == other.url diff --git a/bauh/view/qt/thread.py b/bauh/view/qt/thread.py index 3066802a..09ab0824 100644 --- a/bauh/view/qt/thread.py +++ b/bauh/view/qt/thread.py @@ -929,4 +929,4 @@ class IgnorePackageUpdates(AsyncAction): self.notify_finished(res) finally: - self.pkg = None \ No newline at end of file + self.pkg = None diff --git a/bauh/view/qt/view_model.py b/bauh/view/qt/view_model.py index 31de653b..8540fac6 100644 --- a/bauh/view/qt/view_model.py +++ b/bauh/view/qt/view_model.py @@ -28,3 +28,7 @@ class PackageView: def __repr__(self): return '{} ( {} )'.format(self.model.name, self.get_type_label()) + + def __eq__(self, other): + if isinstance(other, PackageView): + return self.model == other.model diff --git a/bauh/view/qt/window.py b/bauh/view/qt/window.py index 14e74d2e..985f0078 100755 --- a/bauh/view/qt/window.py +++ b/bauh/view/qt/window.py @@ -1277,6 +1277,12 @@ class ManageWindow(QWidget): if res['success']: self.apply_filters_async() + if self.pkgs_installed: + cached_installed = [idx for idx, p in enumerate(self.pkgs_installed) if p == res['pkg']] + + for idx in cached_installed: + self.pkgs_installed[idx] = res['pkg'] + dialog.show_message(title=self.i18n['success'].capitalize(), body=self.i18n['action.{}.success'.format(res['action'])].format(bold(res['pkg'].model.name)), type_=MessageType.INFO)