Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass store to disposableTimeout #193796

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/vs/platform/extensionManagement/common/extensionTipsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { isNonEmptyArray } from 'vs/base/common/arrays';
import { Disposable } from 'vs/base/common/lifecycle';
import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle';
import { IConfigBasedExtensionTip as IRawConfigBasedExtensionTip } from 'vs/base/common/product';
import { joinPath } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
Expand Down Expand Up @@ -154,11 +154,11 @@ export abstract class AbstractNativeExtensionTipsService extends ExtensionTipsSe
3s has come out to be the good number to fetch and prompt important exe based recommendations
Also fetch important exe based recommendations for reporting telemetry
*/
this._register(disposableTimeout(async () => {
disposableTimeout(async () => {
await this.collectTips();
this.promptHighImportanceExeBasedTip();
this.promptMediumImportanceExeBasedTip();
}, 3000));
}, 3000, this._store);
}

override async getImportantExecutableBasedTips(): Promise<IExecutableBasedExtensionTip[]> {
Expand Down Expand Up @@ -243,7 +243,8 @@ export abstract class AbstractNativeExtensionTipsService extends ExtensionTipsSe
}
case RecommendationsNotificationResult.TooMany: {
// Too many notifications. Schedule the prompt after one hour
const disposable = this._register(disposableTimeout(() => { disposable.dispose(); this.promptHighImportanceExeBasedTip(); }, 60 * 60 * 1000 /* 1 hour */));
const disposable = this._register(new MutableDisposable());
disposable.value = disposableTimeout(() => { disposable.dispose(); this.promptHighImportanceExeBasedTip(); }, 60 * 60 * 1000 /* 1 hour */);
break;
}
}
Expand All @@ -263,7 +264,8 @@ export abstract class AbstractNativeExtensionTipsService extends ExtensionTipsSe
const promptInterval = 7 * 24 * 60 * 60 * 1000; // 7 Days
if (timeSinceLastPrompt < promptInterval) {
// Wait until interval and prompt
const disposable = this._register(disposableTimeout(() => { disposable.dispose(); this.promptMediumImportanceExeBasedTip(); }, promptInterval - timeSinceLastPrompt));
const disposable = this._register(new MutableDisposable());
disposable.value = disposableTimeout(() => { disposable.dispose(); this.promptMediumImportanceExeBasedTip(); }, promptInterval - timeSinceLastPrompt);
return;
}

Expand All @@ -278,7 +280,8 @@ export abstract class AbstractNativeExtensionTipsService extends ExtensionTipsSe
this.addToRecommendedExecutables(tips[0].exeName, tips);

// Schedule the next recommendation for next internval
const disposable1 = this._register(disposableTimeout(() => { disposable1.dispose(); this.promptMediumImportanceExeBasedTip(); }, promptInterval));
const disposable1 = this._register(new MutableDisposable());
disposable1.value = disposableTimeout(() => { disposable1.dispose(); this.promptMediumImportanceExeBasedTip(); }, promptInterval);
break;
}
case RecommendationsNotificationResult.Ignored:
Expand All @@ -295,7 +298,8 @@ export abstract class AbstractNativeExtensionTipsService extends ExtensionTipsSe
}
case RecommendationsNotificationResult.TooMany: {
// Too many notifications. Schedule the prompt after one hour
const disposable2 = this._register(disposableTimeout(() => { disposable2.dispose(); this.promptMediumImportanceExeBasedTip(); }, 60 * 60 * 1000 /* 1 hour */));
const disposable2 = this._register(new MutableDisposable());
disposable2.value = disposableTimeout(() => { disposable2.dispose(); this.promptMediumImportanceExeBasedTip(); }, 60 * 60 * 1000 /* 1 hour */);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,10 @@ class AutoSync extends Disposable {
}

private waitUntilNextIntervalAndSync(): void {
this.intervalHandler.value = disposableTimeout(() => this.sync(AutoSync.INTERVAL_SYNCING, false), this.interval);
this.intervalHandler.value = disposableTimeout(() => {
this.sync(AutoSync.INTERVAL_SYNCING, false);
this.intervalHandler.value = undefined;
}, this.interval);
}

sync(reason: string, disableCache: boolean): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class FileBasedRecommendations extends ExtensionRecommendations {
}

// re-schedule this bit of the operation to be off the critical path - in case glob-match is slow
this._register(disposableTimeout(() => this.promptImportantRecommendations(uri, model), 0));
disposableTimeout(() => this.promptImportantRecommendations(uri, model), 0, this._store);
}

/**
Expand Down Expand Up @@ -232,12 +232,12 @@ export class FileBasedRecommendations extends ExtensionRecommendations {
const disposables = new DisposableStore();
disposables.add(model.onDidChangeLanguage(() => {
// re-schedule this bit of the operation to be off the critical path - in case glob-match is slow
disposables.add(disposableTimeout(() => {
disposableTimeout(() => {
if (!disposables.isDisposed) {
this.promptImportantRecommendations(uri, model, unmatchedRecommendations);
disposables.dispose();
}
}, 0));
}, 0, disposables);
}));
disposables.add(model.onWillDispose(() => disposables.dispose()));
}
Expand Down