Enable file provider domains per the settings in the file provider domain manager

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-09-06 15:42:12 +08:00
parent 1db59fecc1
commit ee6c081603
No known key found for this signature in database
GPG key ID: C839200C384636B0
3 changed files with 19 additions and 1 deletions

View file

@ -19,6 +19,7 @@
#include "config.h" #include "config.h"
#include "fileproviderdomainmanager.h" #include "fileproviderdomainmanager.h"
#include "fileprovidersettingscontroller.h"
#include "pushnotifications.h" #include "pushnotifications.h"
#include "gui/accountmanager.h" #include "gui/accountmanager.h"
@ -447,10 +448,21 @@ void FileProviderDomainManager::setupFileProviderDomains()
d->findExistingFileProviderDomains(); d->findExistingFileProviderDomains();
for(auto &accountState : AccountManager::instance()->accounts()) { const auto vfsEnabledAccounts = FileProviderSettingsController::instance()->vfsEnabledAccounts();
auto domainsToRemove = d->configuredDomainIds();
for (const auto &accountUserIdAtHost : vfsEnabledAccounts) {
domainsToRemove.removeAll(accountUserIdAtHost);
const auto accountState = AccountManager::instance()->accountFromUserId(accountUserIdAtHost);
addFileProviderDomainForAccount(accountState.data()); addFileProviderDomainForAccount(accountState.data());
} }
for (const auto &remainingDomainUserId : domainsToRemove) {
const auto accountState = AccountManager::instance()->accountFromUserId(remainingDomainUserId);
removeFileProviderDomainForAccount(accountState.data());
}
emit domainSetupComplete(); emit domainSetupComplete();
} }

View file

@ -32,6 +32,7 @@ public:
QWidget *const parent = nullptr, QWidget *const parent = nullptr,
const QQuickWidget::ResizeMode resizeMode = QQuickWidget::SizeRootObjectToView); const QQuickWidget::ResizeMode resizeMode = QQuickWidget::SizeRootObjectToView);
[[nodiscard]] QStringList vfsEnabledAccounts() const;
[[nodiscard]] Q_INVOKABLE bool vfsEnabledForAccount(const QString &userIdAtHost) const; [[nodiscard]] Q_INVOKABLE bool vfsEnabledForAccount(const QString &userIdAtHost) const;
public slots: public slots:

View file

@ -183,6 +183,11 @@ QQuickWidget *FileProviderSettingsController::settingsViewWidget(const QString &
return settingsViewWidget; return settingsViewWidget;
} }
QStringList FileProviderSettingsController::vfsEnabledAccounts() const
{
return d->enabledAccounts();
}
bool FileProviderSettingsController::vfsEnabledForAccount(const QString &userIdAtHost) const bool FileProviderSettingsController::vfsEnabledForAccount(const QString &userIdAtHost) const
{ {
return d->vfsEnabledForAccount(userIdAtHost); return d->vfsEnabledForAccount(userIdAtHost);