Skip to content

Commit 235e42d

Browse files
committed
Fix update notification continually showing
This would happen if the workspace was up to date but then got an update after being connected. Fixes #307.
1 parent bcf5486 commit 235e42d

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Fixed
6+
7+
- Fix the update dialog continually reappearing.
8+
59
## [v1.2.0](https://github.com/coder/vscode-coder/releases/tag/v1.2.0) (2024-06-21)
610

711
### Added

src/remote.ts

+17-19
Original file line numberDiff line numberDiff line change
@@ -400,27 +400,25 @@ export class Remote {
400400
let hasShownOutdatedNotification = false
401401
const refreshWorkspaceUpdatedStatus = (newWorkspace: Workspace) => {
402402
// If the newly gotten workspace was updated, then we show a notification
403-
// to the user that they should update.
404-
if (newWorkspace.outdated) {
405-
if (!workspace.outdated || !hasShownOutdatedNotification) {
406-
hasShownOutdatedNotification = true
407-
workspaceRestClient
408-
.getTemplate(newWorkspace.template_id)
409-
.then((template) => {
410-
return workspaceRestClient.getTemplateVersion(template.active_version_id)
411-
})
412-
.then((version) => {
413-
let infoMessage = `A new version of your workspace is available.`
414-
if (version.message) {
415-
infoMessage = `A new version of your workspace is available: ${version.message}`
403+
// to the user that they should update. Only show this once per session.
404+
if (newWorkspace.outdated && !hasShownOutdatedNotification) {
405+
hasShownOutdatedNotification = true
406+
workspaceRestClient
407+
.getTemplate(newWorkspace.template_id)
408+
.then((template) => {
409+
return workspaceRestClient.getTemplateVersion(template.active_version_id)
410+
})
411+
.then((version) => {
412+
let infoMessage = `A new version of your workspace is available.`
413+
if (version.message) {
414+
infoMessage = `A new version of your workspace is available: ${version.message}`
415+
}
416+
vscode.window.showInformationMessage(infoMessage, "Update").then((action) => {
417+
if (action === "Update") {
418+
vscode.commands.executeCommand("coder.workspace.update", newWorkspace, workspaceRestClient)
416419
}
417-
vscode.window.showInformationMessage(infoMessage, "Update").then((action) => {
418-
if (action === "Update") {
419-
vscode.commands.executeCommand("coder.workspace.update", newWorkspace, workspaceRestClient)
420-
}
421-
})
422420
})
423-
}
421+
})
424422
}
425423
if (!newWorkspace.outdated) {
426424
vscode.commands.executeCommand("setContext", "coder.workspace.updatable", false)

0 commit comments

Comments
 (0)