[improvement][ui] not performing a full table refresh after installing a new package

This commit is contained in:
Vinicius Moreira
2020-06-11 16:51:55 -03:00
parent cc5c89a350
commit a43e640437
11 changed files with 183 additions and 70 deletions

View File

@@ -631,17 +631,20 @@ class InstallPackage(AsyncAction):
def run(self):
if self.pkg:
success = False
res = {'success': False, 'installed': None, 'removed': None, 'pkg': self.pkg}
if self.pkg.model.supports_backup():
if not self.request_backup(read_config(), 'install', self.i18n, self.root_pwd):
self.signal_finished.emit({'success': False, 'pkg': self.pkg})
self.signal_finished.emit(res)
return
try:
success = self.manager.install(self.pkg.model, self.root_pwd, self)
transaction_res = self.manager.install(self.pkg.model, self.root_pwd, None, self)
res['success'] = transaction_res.success
res['installed'] = transaction_res.installed
res['removed'] = transaction_res.removed
if success:
if transaction_res.success:
self.pkg.model.installed = True
if self.pkg.model.supports_disk_cache():
@@ -650,10 +653,10 @@ class InstallPackage(AsyncAction):
icon_bytes=icon_data.get('bytes') if icon_data else None,
only_icon=False)
except (requests.exceptions.ConnectionError, NoInternetException):
success = False
res['success'] = False
self.print(self.i18n['internet.required'])
finally:
self.signal_finished.emit({'success': success, 'pkg': self.pkg})
self.signal_finished.emit(res)
self.pkg = None

View File

@@ -1211,7 +1211,23 @@ class ManageWindow(QWidget):
if self._can_notify_user():
util.notify_user(msg='{} ({}) {}'.format(res['pkg'].model.name, res['pkg'].model.get_type(), self.i18n['installed']))
self._finish_refresh_apps({'installed': [res['pkg'].model], 'total': 1, 'types': None})
models_updated = []
for key in ('installed', 'removed'):
if res.get(key):
models_updated.extend(res[key])
if models_updated:
view_to_update = []
for displayed in self.pkgs:
for p in models_updated:
if displayed.model == p:
displayed.model = p
view_to_update.append(displayed)
for pkgv in view_to_update:
self.table_apps.update_package(pkgv)
self.ref_bt_installed.setVisible(False)
self.ref_checkbox_only_apps.setVisible(False)
self.update_custom_actions()
@@ -1324,3 +1340,4 @@ class ManageWindow(QWidget):
body=self.i18n['action.{}.fail'.format(res['action'])].format(bold(res['pkg'].model.name)),
type_=MessageType.ERROR)