[gnome-software] flatpak: Set new state immediately when installing/removing/updating



commit e0aeacc39097dcb65d5d9d6b75b65114ac50792e
Author: Kalev Lember <klember redhat com>
Date:   Wed Oct 10 12:49:51 2018 +0200

    flatpak: Set new state immediately when installing/removing/updating
    
    Otherwise the UI doesn't refresh and keeps showing e.g. the Install
    button until we eventually get a FlatpakTransaction new operation
    callback.

 plugins/flatpak/gs-plugin-flatpak.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index fb07c9b4..1b7c4d58 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -521,9 +521,13 @@ gs_plugin_app_remove (GsPlugin *plugin,
                gs_flatpak_error_convert (error);
                return FALSE;
        }
+
+       /* run transaction */
+       gs_app_set_state (app, AS_APP_STATE_REMOVING);
        if (!gs_flatpak_transaction_run (transaction, cancellable, error)) {
                g_prefix_error (error, "failed to run transaction for %s: ", ref);
                gs_flatpak_error_convert (error);
+               gs_app_set_state_recover (app);
                return FALSE;
        }
 
@@ -657,10 +661,12 @@ gs_plugin_app_install (GsPlugin *plugin,
        }
 
        /* run transaction */
+       gs_app_set_state (app, AS_APP_STATE_INSTALLING);
        if (!gs_flatpak_transaction_run (transaction, cancellable, error)) {
                g_prefix_error (error, "failed to run transaction for %s: ",
                                gs_app_get_unique_id (app));
                gs_flatpak_error_convert (error);
+               gs_app_set_state_recover (app);
                return FALSE;
        }
 
@@ -707,9 +713,13 @@ gs_plugin_update_app (GsPlugin *plugin,
                gs_flatpak_error_convert (error);
                return FALSE;
        }
+
+       /* run transaction */
+       gs_app_set_state (app, AS_APP_STATE_INSTALLING);
        if (!gs_flatpak_transaction_run (transaction, cancellable, error)) {
                g_prefix_error (error, "failed to run transaction for %s: ", ref);
                gs_flatpak_error_convert (error);
+               gs_app_set_state_recover (app);
                return FALSE;
        }
        gs_plugin_updates_changed (plugin);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]