Add refresh lockout to package uninstalls

This commit is contained in:
heliguy4599
2024-10-11 16:10:37 -04:00
parent 45fb11efa2
commit 7045edb78a
2 changed files with 9 additions and 1 deletions

View File

@@ -98,10 +98,16 @@ class Flatpak:
Gio.Task.new(None, None, callback).run_in_thread(thread)
def uninstall(self, callback=None):
def uninstall(self, callee_callback=None):
self.failed_uninstall = None
def callback(*args):
HostInfo.main_window.remove_refresh_lockout("uninstalling packages")
if not callee_callback is None:
callee_callback()
def thread(*args):
HostInfo.main_window.add_refresh_lockout("uninstalling packages")
cmd = ['flatpak-spawn', '--host', 'flatpak', 'uninstall', '-y', self.info["ref"]]
installation = self.info["installation"]
if installation == "system" or installation == "user":

View File

@@ -243,6 +243,7 @@ class PackagesPage(Adw.BreakpointBin):
GLib.idle_add(lambda *_: self.set_status(self.uninstalling))
error = [None]
def thread(*args):
HostInfo.main_window.add_refresh_lockout("batch uninstalling packages")
cmd = ['flatpak-spawn', '--host', 'flatpak', 'uninstall', '-y']
to_trash = []
for row in self.selected_rows:
@@ -261,6 +262,7 @@ class PackagesPage(Adw.BreakpointBin):
def callback(*args):
self.main_window.refresh_handler()
HostInfo.main_window.remove_refresh_lockout("batch uninstalling packages")
if err := error[0]:
details = err.stderr if type(err) == subprocess.CalledProcessError else str(err)
GLib.idle_add(lambda *args: self.packages_toast_overlay.add_toast(ErrorToast(_("Could not uninstall packages"), details).toast))