diff --git a/libnymea-app-core/connection/nymeaconnection.cpp b/libnymea-app-core/connection/nymeaconnection.cpp index d0b6a188..fbc87a87 100644 --- a/libnymea-app-core/connection/nymeaconnection.cpp +++ b/libnymea-app-core/connection/nymeaconnection.cpp @@ -499,14 +499,12 @@ void NymeaConnection::connectInternal(NymeaHost *host) } } - if (m_availableBearerTypes.testFlag(Connection::BearerTypeCloud)) { - Connection* wanConnection = host->connections()->bestMatch(Connection::BearerTypeCloud); - if (wanConnection) { - qDebug() << "Best candidate WAN connection:" << wanConnection->url(); - connectInternal(wanConnection); - } else { - qDebug() << "No available WAN connection to" << host->name(); - } + Connection* wanConnection = host->connections()->bestMatch(Connection::BearerTypeCloud); + if (wanConnection) { + qDebug() << "Best candidate WAN connection:" << wanConnection->url(); + connectInternal(wanConnection); + } else { + qDebug() << "No available WAN connection to" << host->name(); } } diff --git a/libnymea-app-core/connection/nymeahosts.cpp b/libnymea-app-core/connection/nymeahosts.cpp index 18b6987e..9793eefd 100644 --- a/libnymea-app-core/connection/nymeahosts.cpp +++ b/libnymea-app-core/connection/nymeahosts.cpp @@ -207,10 +207,18 @@ bool NymeaHostsFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s bool hasReachableConnection = false; for (int i = 0; i < host->connections()->rowCount(); i++) { // qDebug() << "checking host for available bearer" << host->name() << host->connections()->get(i)->url() << "available bearer types:" << m_nymeaConnection->availableBearerTypes() << "hosts bearer types" << host->connections()->get(i)->bearerType(); + // Either enable a connection when the Bearer type is directly available if (m_nymeaConnection->availableBearerTypes().testFlag(host->connections()->get(i)->bearerType())) { hasReachableConnection = true; break; } + // or enable it if it is Cloud and we have access to LAN or WIFI + if (host->connections()->get(i)->bearerType() == Connection::BearerTypeCloud) { + if (m_nymeaConnection->availableBearerTypes().testFlag(Connection::BearerTypeWifi) || m_nymeaConnection->availableBearerTypes().testFlag(Connection::BearerTypeEthernet)) { + hasReachableConnection = true; + break; + } + } } if (!hasReachableConnection) { return false; diff --git a/nymea-app/ui/MainPage.qml b/nymea-app/ui/MainPage.qml index 09aa1170..439d7fbd 100644 --- a/nymea-app/ui/MainPage.qml +++ b/nymea-app/ui/MainPage.qml @@ -39,6 +39,12 @@ Page { // Load current index from settings currentViewIndex = tabSettings.currentMainViewIndex; + + // If setting is not initialized yet, init to "Things" page (might be 0 or 1, depending whether we have tags support) + if (currentViewIndex === -1) { + currentViewIndex = engine.jsonRpcClient.ensureServerVersion(1.6) ? 1 : 0 + } + // and set up a binding to sync changes back to the settings tabSettings.currentMainViewIndex = Qt.binding(function() { return root.currentViewIndex; }); diff --git a/nymea-app/ui/RootItem.qml b/nymea-app/ui/RootItem.qml index 8d87e6d4..c70a0dda 100644 --- a/nymea-app/ui/RootItem.qml +++ b/nymea-app/ui/RootItem.qml @@ -80,7 +80,7 @@ Item { property var tabSettings: Settings { category: "tabSettings" + index property string lastConnectedHost - property int currentMainViewIndex: 0 + property int currentMainViewIndex: -1 } Engine { @@ -97,6 +97,13 @@ Item { value: "cloudEnvironment" in app ? app.cloudEnvironment : settings.cloudEnvironment } + Binding { + target: discovey + property: "discovering" + when: engine.connection.currentHost === null + value: true + } + Component.onCompleted: { if (tabSettings.lastConnectedHost.length > 0) { print("Last connected host was", tabSettings.lastConnectedHost)