Skip to content

Commit afbb874

Browse files
committed
fix(file-provider): Actually enable or disable file provider domain in settings.
Signed-off-by: Iva Horn <[email protected]>
1 parent e83fae9 commit afbb874

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/gui/macOS/fileproviderdomainmanager.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ public slots:
4343
*/
4444
QString addFileProviderDomainForAccount(const OCC::AccountState * const accountState);
4545

46+
/**
47+
* @brief Remove the file provider domain for the given account.
48+
*/
49+
void removeFileProviderDomainForAccount(const OCC::AccountState * const accountState);
50+
4651
private slots:
4752
void updateFileProviderDomains();
4853

49-
void removeFileProviderDomainForAccount(const OCC::AccountState * const accountState);
5054
void disconnectFileProviderDomainForAccount(const OCC::AccountState * const accountState, const QString &reason);
5155
void reconnectFileProviderDomainForAccount(const OCC::AccountState * const accountState);
5256

src/gui/macOS/fileprovidersettingscontroller_mac.mm

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ explicit MacImplementation(FileProviderSettingsController *const parent)
8585

8686
const auto existingDomainId = q->fileProviderDomainIdentifierForAccount(userIdAtHost);
8787

88-
if (existingDomainId.isEmpty() == false) {
88+
if (setEnabled && existingDomainId.isEmpty() == false) {
8989
qCWarning(lcFileProviderSettingsController) << "Cancelling because account already has a domain identifier!" << userIdAtHost;
9090
return VfsAccountsAction::VfsAccountsNoAction;
9191
}
@@ -94,15 +94,17 @@ explicit MacImplementation(FileProviderSettingsController *const parent)
9494
const auto accountState = accountManager->accountFromUserId(userIdAtHost);
9595

9696
if (!accountState) {
97-
qCWarning(lcFileProviderSettingsController) << "Unable to set file provider enablement, account not found!"
98-
<< userIdAtHost;
97+
qCWarning(lcFileProviderSettingsController) << "Unable to set file provider enablement, account not found!" << userIdAtHost;
9998
return VfsAccountsAction::VfsAccountsNoAction;
10099
}
101100

102-
const auto account = accountState->account();
103-
104-
auto const identifier = Mac::FileProvider::instance()->domainManager()->addFileProviderDomainForAccount(accountState.data());
105-
accountManager->setFileProviderDomainIdentifier(userIdAtHost, identifier);
101+
if (setEnabled) {
102+
auto const identifier = Mac::FileProvider::instance()->domainManager()->addFileProviderDomainForAccount(accountState.data());
103+
accountManager->setFileProviderDomainIdentifier(userIdAtHost, identifier);
104+
} else {
105+
Mac::FileProvider::instance()->domainManager()->removeFileProviderDomainForAccount(accountState.data());
106+
accountManager->setFileProviderDomainIdentifier(userIdAtHost, "");
107+
}
106108

107109
return VfsAccountsAction::VfsAccountsEnabledChanged;
108110
}

0 commit comments

Comments
 (0)