Skip to content

Commit 1f9b031

Browse files
committed
fix: only check for updates on activation, not refresh
1 parent 92c01a5 commit 1f9b031

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function activate(context: vscode.ExtensionContext) {
1313
taskExtension.registerListeners(context);
1414

1515
// Refresh the tasks list
16-
taskExtension.updateAndRefresh();
16+
taskExtension.refresh();
1717
}
1818

1919
export function deactivate() { }

src/services/taskfile.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ class TaskfileService {
3535
return `${settings.path} ${command}`;
3636
}
3737

38-
public async checkInstallation(): Promise<string> {
38+
public async checkInstallation(checkForUpdates?: boolean): Promise<string> {
39+
if (checkForUpdates === undefined) {
40+
checkForUpdates = settings.checkForUpdates;
41+
}
3942
return await new Promise((resolve) => {
4043
let command = this.command('--version');
4144
cp.exec(command, (_, stdout: string, stderr: string) => {
@@ -65,7 +68,7 @@ class TaskfileService {
6568

6669
// If a newer version is available, show a message
6770
// TODO: what happens if the user is offline?
68-
if (settings.checkForUpdates) {
71+
if (checkForUpdates) {
6972
this.getLatestVersion().then((latestVersion) => {
7073
if (version && latestVersion && version.compare(latestVersion) < 0) {
7174
log.info(`A new version of Task is available. Current version: v${version}, Latest version: v${latestVersion}`);
@@ -77,6 +80,8 @@ class TaskfileService {
7780
return resolve("notInstalled");
7881
});
7982
}
83+
84+
return resolve("ready");
8085
});
8186
});
8287
}

src/task.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export class TaskExtension {
1515
this.setTreeNesting(settings.treeNesting);
1616
}
1717

18-
public async update(): Promise<void> {
18+
public async update(checkForUpdates?: boolean): Promise<void> {
1919
// Do version checks
20-
await services.taskfile.checkInstallation().then((status): Promise<PromiseSettledResult<models.Taskfile>[]> => {
20+
await services.taskfile.checkInstallation(checkForUpdates).then((status): Promise<PromiseSettledResult<models.Taskfile>[]> => {
2121

2222
// Set the status
2323
vscode.commands.executeCommand('setContext', 'vscode-task:status', status);
@@ -43,13 +43,9 @@ export class TaskExtension {
4343
});
4444
}
4545

46-
public refresh(): void {
47-
this._activityBar.refresh(this._taskfiles);
48-
}
49-
50-
public async updateAndRefresh(): Promise<void> {
51-
await this.update().then(() => {
52-
this.refresh();
46+
public async refresh(checkForUpdates?: boolean): Promise<void> {
47+
await this.update(checkForUpdates).then(() => {
48+
this._activityBar.refresh(this._taskfiles);
5349
}).catch((err: string) => {
5450
log.error(err);
5551
});
@@ -86,7 +82,7 @@ export class TaskExtension {
8682
// Refresh tasks
8783
context.subscriptions.push(vscode.commands.registerCommand('vscode-task.refresh', () => {
8884
log.info("Command: vscode-task.refresh");
89-
this.updateAndRefresh();
85+
this.refresh(false);
9086
}));
9187

9288
// View tasks as list
@@ -200,7 +196,7 @@ export class TaskExtension {
200196
log.info("Detected changes to taskfile");
201197
// If manual updating is turned off (update on save)
202198
if (settings.updateOn !== "manual") {
203-
await this.updateAndRefresh();
199+
await this.refresh(false);
204200
}
205201
}
206202

0 commit comments

Comments
 (0)