gnome: move offhold check

Move offhold check to catch the case in which a call
is hung up and we automatically swith to another
existing call. Otherwise, in this case, the other
existing call remains on hold.

Refs #76488

Change-Id: I066faaed545dc0257770e3669df6f6efde49a685
diff --git a/src/callsview.cpp b/src/callsview.cpp
index ff7184b..5ec891d 100644
--- a/src/callsview.cpp
+++ b/src/callsview.cpp
@@ -66,10 +66,18 @@
 update_call_model_selection(GtkTreeSelection *selection, G_GNUC_UNUSED gpointer user_data)
 {
     QModelIndex current = get_index_from_selection(selection);
-    if (current.isValid())
+    if (current.isValid()) {
+
+        /* if the call is on hold, we want to put it off hold automatically
+         * when switching to it */
+        auto call = CallModel::instance()->getCall(current);
+        if (call->state() == Call::State::HOLD)
+            call << Call::Action::HOLD;
+
         CallModel::instance()->selectionModel()->setCurrentIndex(current, QItemSelectionModel::ClearAndSelect);
-    else
+    } else {
         CallModel::instance()->selectionModel()->clearCurrentIndex();
+    }
 }
 
 static void
@@ -263,14 +271,6 @@
                     g_warning("SelectionModel of CallModel changed to invalid QModelIndex?");
                 }
             }
-
-            /* if the call is on hold, we want to put it off hold automatically
-             * when switching to it */
-            if (current.isValid()) {
-                auto call = CallModel::instance()->getCall(current);
-                if (call->state() == Call::State::HOLD)
-                    call << Call::Action::HOLD;
-            }
         }
     );