Update proper pages when package user data is trashed

This commit is contained in:
heliguy4599
2024-10-13 13:44:42 -04:00
parent 9ccd84dedf
commit 71aba825fa
4 changed files with 14 additions and 3 deletions

View File

@@ -44,8 +44,6 @@ class Flatpak:
def trash_data(self, callback=None):
try:
subprocess.run(['gio', 'trash', self.data_path], capture_output=True, text=True, check=True)
snapshot_list_page = HostInfo.main_window.pages[HostInfo.main_window.snapshots_row].list_page
snapshot_list_page.set_snapshots(snapshot_list_page.package_or_folder, True)
except subprocess.CalledProcessError as cpe:
raise cpe
except Exception as e:

View File

@@ -168,6 +168,11 @@ class PropertiesPage(Adw.NavigationPage):
self.package.trash_data()
self.set_properties(self.package, refresh=True)
self.toast_overlay.add_toast(Adw.Toast.new("Trashed User Data"))
snapshot_list_page = HostInfo.main_window.pages[HostInfo.main_window.snapshots_row].list_page
snapshot_list_page.set_snapshots(snapshot_list_page.package_or_folder, True)
user_data_page = HostInfo.main_window.pages[HostInfo.main_window.user_data_row]
user_data_page.start_loading()
user_data_page.end_loading()
except subprocess.CalledProcessError as cpe:
self.toast_overlay.add_toast(ErrorToast(_("Could not trash data"), cpe.stderr).toast)
except Exception as e:

View File

@@ -79,6 +79,10 @@ class DataBox(Gtk.ListBox):
def thread(*args):
try:
subprocess.run(['gio', 'trash', self.data_path], check=True, text=True, capture_output=True)
properties_page = HostInfo.main_window.pages[HostInfo.main_window.packages_row].properties_page
properties_page.set_properties(properties_page.package, True)
snapshot_list_page = HostInfo.main_window.pages[HostInfo.main_window.snapshots_row].list_page
snapshot_list_page.set_snapshots(snapshot_list_page.package_or_folder, True)
except subprocess.CalledProcessError as cpe:
self.failed_trash = cpe.stderr
except Exception as e:

View File

@@ -163,6 +163,10 @@ class UserDataPage(Adw.BreakpointBin):
cmd = ['gio', 'trash'] + path
try:
subprocess.run(cmd, check=True, capture_output=True, text=True)
properties_page = HostInfo.main_window.pages[HostInfo.main_window.packages_row].properties_page
properties_page.set_properties(properties_page.package, True)
snapshot_list_page = HostInfo.main_window.pages[HostInfo.main_window.snapshots_row].list_page
snapshot_list_page.set_snapshots(snapshot_list_page.package_or_folder, True)
except subprocess.CalledProcessError as cpe:
error[0] = cpe.stderr
except Exception as e:
@@ -190,7 +194,7 @@ class UserDataPage(Adw.BreakpointBin):
return
self.select_button.set_active(False)
child.set_visible_child(child.loading_data)
self.status_stack.set_visible_child(self.loading_view)
Gio.Task.new(None, None, callback).run_in_thread(lambda *_: thread(to_trash))
if len(child.selected_boxes) < 1 or self.is_trash_dialog_open: