Skip to content

Commit 9003c30

Browse files
committed
Add progress notification and update-check translations with a minimum display time
- while checking for new version, show progress notification - checking for updates could be very fast, even too fast. make it tak at least 3s └── apps └── editor ├── package.json ├── package.nls.json └── src ├── commands │ ├── check-for-updates-command.ts │ └── index.ts ├── constants │ └── values.ts ├── extension.ts ├── i18n │ ├── index.ts │ └── translations │ └── commands │ ├── check-for-updates-command.ts │ └── index.ts ├── utils │ └── check-for-updates.ts └── views └── prompt └── backend └── prompt-view-provider.ts
1 parent 128fb91 commit 9003c30

2 files changed

Lines changed: 42 additions & 2 deletions

File tree

‎apps/editor/src/commands/check-for-updates-command.ts‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,35 @@ import { t } from '../i18n'
33
import { PromptViewProvider } from '../views/prompt/backend/prompt-view-provider'
44
import { update_extension } from '../utils/update-extension'
55

6+
const MINIMUM_WAIT_TIME = 2000
7+
68
export const check_for_updates_command = (
79
prompt_view_provider: PromptViewProvider
810
) => {
911
return vscode.commands.registerCommand(
1012
'codeWebChat.checkForUpdates',
1113
async () => {
12-
await prompt_view_provider.check_for_updates()
14+
await vscode.window.withProgress(
15+
{
16+
location: vscode.ProgressLocation.Notification,
17+
title: t(
18+
'command.check-for-updates-command.info.checking-for-updates'
19+
),
20+
cancellable: false
21+
},
22+
async () => {
23+
const start_time = Date.now()
24+
await prompt_view_provider.check_for_updates()
25+
const elapsed_time = Date.now() - start_time
26+
27+
if (elapsed_time < MINIMUM_WAIT_TIME) {
28+
await new Promise((resolve) =>
29+
setTimeout(resolve, MINIMUM_WAIT_TIME - elapsed_time)
30+
)
31+
}
32+
}
33+
)
34+
1335
if (prompt_view_provider.update_info.is_available) {
1436
const action = await vscode.window.showInformationMessage(
1537
t('command.check-for-updates-command.info.new-version-available'),

‎apps/editor/src/i18n/translations/commands/check-for-updates-command.ts‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
export const translations = {
2+
'command.check-for-updates-command.info.checking-for-updates': {
3+
en: 'Checking for updates...',
4+
pl: 'Sprawdzanie aktualizacji...',
5+
'zh-cn': '正在检查更新...',
6+
ja: 'アップデートを確認中...',
7+
'zh-tw': '正在檢查更新...',
8+
de: 'Suche nach Updates...',
9+
es: 'Buscando actualizaciones...',
10+
fr: 'Recherche de mises à jour...',
11+
'pt-br': 'Verificando atualizações...',
12+
ru: 'Проверка обновлений...',
13+
ko: '업데이트 확인 중...',
14+
it: 'Ricerca aggiornamenti in corso...',
15+
tr: 'Güncellemeler kontrol ediliyor...',
16+
cs: 'Kontrola aktualizací...',
17+
hu: 'Frissítések keresése...',
18+
bg: 'Проверка за актуализации...'
19+
},
220
'command.check-for-updates-command.info.new-version-available': {
321
en: 'New version is available!',
422
pl: 'Dostępna jest nowa wersja!',
@@ -53,4 +71,4 @@ export const translations = {
5371
hu: 'Nincsenek elérhető frissítések.',
5472
bg: 'Няма налични актуализации.'
5573
}
56-
} as const
74+
} as const

0 commit comments

Comments
 (0)