Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/vs/platform/userDataSync/common/userDataAutoSyncService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ export class UserDataAutoSyncService extends Disposable implements IUserDataAuto
} else {
this.logService.info('[AutoSync] Disabled.');
}
this.updateAutoSync();
if (this.meteredConnectionService.isConnectionMetered) {
void this.initializeAutoSync();
} else {
this.updateAutoSync();
}

if (this.hasToDisableMachineEventually()) {
this.disableMachineEventually();
Expand All @@ -120,6 +124,13 @@ export class UserDataAutoSyncService extends Disposable implements IUserDataAuto
}
}

private async initializeAutoSync(): Promise<void> {
await this.meteredConnectionService.whenInitialized;
if (!this._store.isDisposed) {
this.updateAutoSync();
}
}

private updateAutoSync(): void {
const { enabled, message } = this.isAutoSyncEnabled();
if (enabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class UserDataSyncClient extends Disposable {
await configurationService.initialize();
this.instantiationService.stub(IConfigurationService, configurationService);

this.instantiationService.stub(IMeteredConnectionService, { isConnectionMetered: false, onDidChangeIsConnectionMetered: new Emitter<boolean>().event });
this.instantiationService.stub(IMeteredConnectionService, { isConnectionMetered: false, whenInitialized: Promise.resolve(), onDidChangeIsConnectionMetered: new Emitter<boolean>().event });

this.instantiationService.stub(IRequestService, this.testServer);

Expand Down