mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 16:44:16 +02:00
Uninstall selected app
This commit is contained in:
@@ -20,3 +20,6 @@ class FlatpakController:
|
||||
|
||||
def get_version(self) -> str:
|
||||
return self.model.get_version()
|
||||
|
||||
def uninstall(self, app_ref: str):
|
||||
return self.model.remove_app(app_ref)
|
||||
|
||||
@@ -81,5 +81,14 @@ def update_and_stream(app_ref: str):
|
||||
return system.stream_cmd(['flatpak', 'update', '-y', app_ref])
|
||||
|
||||
|
||||
def uninstall_and_stream(app_ref: str):
|
||||
"""
|
||||
Removes the app by its reference
|
||||
:param app_ref:
|
||||
:return:
|
||||
"""
|
||||
return system.stream_cmd(['flatpak', 'uninstall', app_ref, '-y'])
|
||||
|
||||
|
||||
def list_updates_as_str():
|
||||
return system.run_cmd('flatpak update', ignore_return_code=True)
|
||||
|
||||
@@ -91,6 +91,12 @@ class FlatpakManager:
|
||||
|
||||
return []
|
||||
|
||||
def _find_by_ref(self, ref: str):
|
||||
package_found = [app for app in self.apps if app['ref'] == ref]
|
||||
|
||||
if package_found:
|
||||
return package_found[0]
|
||||
|
||||
def update_app(self, ref: str):
|
||||
|
||||
"""
|
||||
@@ -100,9 +106,19 @@ class FlatpakManager:
|
||||
|
||||
if self.apps:
|
||||
|
||||
package_found = [app for app in self.apps if app['ref'] == ref]
|
||||
app_found = self._find_by_ref(ref)
|
||||
|
||||
if package_found:
|
||||
if app_found:
|
||||
return flatpak.update_and_stream(ref)
|
||||
|
||||
return None
|
||||
def remove_app(self, ref: str):
|
||||
"""
|
||||
:param ref:
|
||||
:return: the uninstall command stream
|
||||
"""
|
||||
if self.apps:
|
||||
|
||||
app_found = self._find_by_ref(ref)
|
||||
|
||||
if app_found:
|
||||
return flatpak.uninstall_and_stream(ref)
|
||||
|
||||
Reference in New Issue
Block a user