Remove extra check for talk app on server in AccountState.
authorCamila <hello@camila.codes>
Mon, 3 Aug 2020 17:48:33 +0000 (19:48 +0200)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Tue, 4 Aug 2020 16:28:19 +0000 (16:28 +0000)
- Remove repeated hard coded "spreed" string.

Signed-off-by: Camila <hello@camila.codes>
src/gui/accountstate.cpp
src/gui/accountstate.h
src/gui/tray/UserModel.cpp
src/gui/tray/UserModel.h

index be7aa58327f3113413110f98abf4ab1c0ceb240f..3b56a8d7ff91e21178256ba4eb1807ba1d084412 100644 (file)
@@ -44,7 +44,6 @@ AccountState::AccountState(AccountPtr account)
     , _waitingForNewCredentials(false)
     , _maintenanceToConnectedDelay(60000 + (qrand() % (4 * 60000))) // 1-5min delay
     , _remoteWipe(new RemoteWipe(_account))
-    , _hasTalk(false)
 {
     qRegisterMetaType<AccountState *>("AccountState*");
 
@@ -74,11 +73,6 @@ AccountPtr AccountState::account() const
     return _account;
 }
 
-bool AccountState::hasTalk() const
-{
-    return _hasTalk;
-}
-
 AccountState::ConnectionStatus AccountState::connectionStatus() const
 {
     return _connectionStatus;
@@ -444,7 +438,6 @@ void AccountState::slotNavigationAppsFetched(const QJsonDocument &reply, int sta
             qCWarning(lcAccountState) << "Status code " << statusCode << " Not Modified - No new navigation apps.";
         } else {
             _apps.clear();
-            _hasTalk = false;
 
             if(!reply.isEmpty()){
                 auto element = reply.object().value("ocs").toObject().value("data");
@@ -458,9 +451,6 @@ void AccountState::slotNavigationAppsFetched(const QJsonDocument &reply, int sta
                             navLink.value("id").toString(), QUrl(navLink.value("icon").toString()));
 
                         _apps << app;
-
-                        if(app->id() == QLatin1String("spreed"))
-                            _hasTalk = true;
                     }
                 }
             }
index 433fb51161b7f01a9d6c8f6118ee56489527b06c..f1209a47a7f798961c8dd791c6f8c11d15ae4d6f 100644 (file)
@@ -103,8 +103,6 @@ public:
 
     bool isSignedOut() const;
 
-    bool hasTalk() const;
-
     AccountAppList appList() const;
     AccountApp* findApp(const QString &appId) const;
 
@@ -195,7 +193,6 @@ private:
     ConnectionStatus _connectionStatus;
     QStringList _connectionErrors;
     bool _waitingForNewCredentials;
-    bool _hasTalk;
     QElapsedTimer _timeSinceLastETagCheck;
     QPointer<ConnectionValidator> _connectionValidator;
     QByteArray _notificationsEtagResponseHeader;
index f7008c42c61991bd8a76a1c0d361f0667194b410..386c7f76254a12ccaf313df74378c4986c9b8a3c 100644 (file)
@@ -483,7 +483,7 @@ bool User::hasLocalFolder() const
 
 bool User::serverHasTalk() const
 {
-    return _account->hasTalk();
+    return talkApp() != nullptr;
 }
 
 AccountApp *User::talkApp() const
@@ -602,14 +602,6 @@ Q_INVOKABLE QString UserModel::currentUserServer()
     return _users[_currentUserId]->server();
 }
 
-Q_INVOKABLE bool UserModel::currentServerHasTalk()
-{
-    if (_users.isEmpty())
-        return false;
-
-    return _users[_currentUserId]->serverHasTalk();
-}
-
 void UserModel::addUser(AccountStatePtr &user, const bool &isCurrent)
 {
     bool containsUser = false;
@@ -870,9 +862,10 @@ void UserAppsModel::buildAppList()
     }
 
     if (UserModel::instance()->appList().count() > 0) {
+        const auto talkApp = UserModel::instance()->currentUser()->talkApp();
         foreach (AccountApp *app, UserModel::instance()->appList()) {
             // Filter out Talk because we have a dedicated button for it
-            if (app->id() == QLatin1String("spreed"))
+            if (talkApp && app->id() == talkApp->id())
                 continue;
 
             beginInsertRows(QModelIndex(), rowCount(), rowCount());
index 3057f0c28527c8589249b144980cefd605055ff7..10836dfd6b5e820693684caf88d03f6f35da96df 100644 (file)
@@ -113,7 +113,6 @@ public:
     Q_INVOKABLE QString currentUserServer();
     Q_INVOKABLE bool currentUserHasActivities();
     Q_INVOKABLE bool currentUserHasLocalFolder();
-    Q_INVOKABLE bool currentServerHasTalk();
     Q_INVOKABLE int currentUserId() const;
     Q_INVOKABLE bool isUserConnected(const int &id);
     Q_INVOKABLE void switchCurrentUser(const int &id);