To give priority to server susbscriptions and keep listing the right update channels.
Signed-off-by: Camila Ayres <hello@camilasan.com>
account->account()->deleteAppToken();
+ // clean up config from subscriptions if the account removed was the only with valid subscription
+ if (account->account()->serverHasValidSubscription()) {
+ updateServerHasValidSubscriptionConfig();
+ }
+
emit accountSyncConnectionRemoved(account);
emit accountRemoved(account);
}
+void AccountManager::updateServerHasValidSubscriptionConfig()
+{
+ auto serverHasValidSubscription = false;
+ for (const auto &account : _accounts) {
+ if (!account->account()->serverHasValidSubscription()) {
+ continue;
+ }
+
+ serverHasValidSubscription = true;
+ break;
+ }
+
+ ConfigFile().setServerHasValidSubscription(serverHasValidSubscription);
+}
+
AccountPtr AccountManager::createAccount()
{
const auto acc = Account::create();
AccountStatePtr ptr(accountState);
_accounts << ptr;
ptr->trySignIn();
+
+ // update config subscriptions if the account added is the only with valid subscription
+ if (accountState->account()->serverHasValidSubscription() && !ConfigFile().serverHasValidSubscription()) {
+ updateServerHasValidSubscriptionConfig();
+ }
+
emit accountAdded(accountState);
}
// Adds an account to the tracked list, emitting accountAdded()
void addAccountState(AccountState *const accountState);
+ // update config serverHasValidSubscription when accounts list changes
+ void updateServerHasValidSubscriptionConfig();
+
AccountManager() = default;
QList<AccountStatePtr> _accounts;
/// Account ids from settings that weren't read
// Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching)
connect(this, &SettingsDialog::styleChanged, generalSettings, &GeneralSettings::slotStyleChanged);
connect(AccountManager::instance(), &AccountManager::accountAdded, generalSettings, &GeneralSettings::loadUpdateChannelsList);
+ connect(AccountManager::instance(), &AccountManager::accountRemoved, generalSettings, &GeneralSettings::loadUpdateChannelsList);
connect(AccountManager::instance(), &AccountManager::capabilitiesChanged, generalSettings, &GeneralSettings::loadUpdateChannelsList);
QAction *networkAction = createColorAwareAction(QLatin1String(":/client/theme/network.svg"), tr("Network"));