Skip to content

Commit

Permalink
fix(vscode): fix insider version display condition
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jul 2, 2024
1 parent e4e8c8c commit 3194078
Showing 1 changed file with 35 additions and 40 deletions.
75 changes: 35 additions & 40 deletions extensions/vscode/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,35 +254,24 @@ async function doActivate(context: vscode.ExtensionContext, createLc: CreateLang
}

const item = vscode.languages.createLanguageStatusItem('vue-insider', 'vue');
if (!context.extension.packageJSON.version.includes('-insider')) {
item.text = '✨ Get Insiders Edition';
item.severity = vscode.LanguageStatusSeverity.Warning;
}
else {
item.text = '🚀 Insiders Edition';
item.text = 'Checking for Updates...';
item.busy = true;
let succeed = false;
for (const url of [
'https://raw.githubusercontent.com/vuejs/language-tools/HEAD/insiders.json',
'https://cdn.jsdelivr.net/gh/vuejs/language-tools/insiders.json',
]) {
try {
const res = await fetch(url);
onJson(await res.json());
succeed = true;
break;
} catch { }
}
checkUpdate();

async function checkUpdate() {
item.detail = 'Checking for Updates...';
item.busy = true;
let succeed = false;
for (const url of [
'https://raw.githubusercontent.com/vuejs/language-tools/HEAD/insiders.json',
'https://cdn.jsdelivr.net/gh/vuejs/language-tools/insiders.json',
]) {
try {
const res = await fetch(url);
onJson(await res.json());
succeed = true;
break;
} catch { }
}
item.busy = false;
if (!succeed) {
item.detail = 'Failed to Fetch Versions';
item.severity = vscode.LanguageStatusSeverity.Error;
}
item.busy = false;
if (!succeed) {
item.text = 'Failed to Fetch Versions';
item.severity = vscode.LanguageStatusSeverity.Error;
}

function onJson(json: {
Expand All @@ -301,19 +290,25 @@ async function doActivate(context: vscode.ExtensionContext, createLc: CreateLang
title: 'Select Version',
command: 'vue-insiders.update',
};
if (
json.versions.some(version => version.version === context.extension.packageJSON.version)
&& context.extension.packageJSON.version !== json.latest
) {
item.detail = 'New Version Available!';
if (json.versions.some(version => version.version === context.extension.packageJSON.version)) {
item.text = '🚀 Insiders Edition';
item.severity = vscode.LanguageStatusSeverity.Information;

if (context.extension.packageJSON.version !== json.latest) {
item.detail = 'New Version Available!';
item.severity = vscode.LanguageStatusSeverity.Warning;
vscode.window
.showInformationMessage('New Insiders Version Available!', 'Download')
.then(download => {
if (download) {
vscode.commands.executeCommand('vue-insiders.update');
}
});
}
}
else {
item.text = '✨ Get Insiders Edition';
item.severity = vscode.LanguageStatusSeverity.Warning;
vscode.window
.showInformationMessage('New Insiders Version Available!', 'Download')
.then(download => {
if (download) {
vscode.commands.executeCommand('vue-insiders.update');
}
});
}
vscode.commands.registerCommand('vue-insiders.update', async () => {
const quickPickItems: { [version: string]: vscode.QuickPickItem; } = {};
Expand Down

2 comments on commit 3194078

@SoCuul
Copy link

@SoCuul SoCuul commented on 3194078 Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnsoncodehk What happened to what you said in the discussion about the upgrade prompt being no longer displayed in future versions?
#4127 (comment)

The "Get Insiders Edition" notification leads the notification icon to be essentially useless in VSCode, as it's always present with this extension.
image

@martijnrondeel
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnsoncodehk would you be open for a PR that changes the severity of this notification from Warning to Information? As commented above the notification icon right now indicates that there is some sort of problem with the extension, even though it's working fine.

Please sign in to comment.