mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-09 16:24:45 +01:00
extensions: show configured auto-update delay in delayed label (#322301)
* extensions: show configured auto-update delay in delayed label The extension status label hardcoded "2 hours" as the auto-update delay, so changing extensions.autoUpdateDelay still showed 2h. Add a getAutoUpdateDelay() method that returns the configured delay and use it to format the label dynamically. Fixes #321577 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * extensions: format auto-update delay as a duration Use a past timestamp with fromNow so the configured delay reads as a duration (e.g. "2 hours") instead of "in 2 hours". Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
13112d5489
commit
a0f60b2860
@@ -2861,9 +2861,10 @@ export class ExtensionStatusAction extends ExtensionAction {
|
||||
this.updateStatus({ icon: warningIcon, message: markdown }, true);
|
||||
}
|
||||
if (this.extensionsWorkbenchService.isAutoUpdateDelayed(this.extension)) {
|
||||
const delay = fromNow(Date.now() - this.extensionsWorkbenchService.getAutoUpdateDelay(), false, true);
|
||||
const updateAt = fromNow(Date.now() + this.extensionsWorkbenchService.getAutoUpdateDelayRemaining(this.extension), false, true);
|
||||
// Do not override the higher-priority warning class with the info class.
|
||||
this.updateStatus({ icon: infoIcon, message: new MarkdownString(localize('autoUpdateDelayed', "This extension is not updated yet because new versions are auto updated 2 hours after they are published. It will be auto updated {0}.", updateAt)) }, !hasConsentWarning);
|
||||
this.updateStatus({ icon: infoIcon, message: new MarkdownString(localize('autoUpdateDelayed', "This extension is not updated yet because new versions are auto updated {0} after they are published. It will be auto updated {1}.", delay, updateAt)) }, !hasConsentWarning);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1260,11 +1260,15 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
|
||||
// Future timestamp (clock skew) — treat as not delayed
|
||||
return 0;
|
||||
}
|
||||
const delayHours = this.configurationService.getValue<number>(AutoUpdateDelayConfigurationKey) ?? 2;
|
||||
const delayPeriod = delayHours * 60 * 60 * 1000; // Convert hours to milliseconds
|
||||
const delayPeriod = this.getAutoUpdateDelay();
|
||||
return Math.max(0, delayPeriod - elapsed);
|
||||
}
|
||||
|
||||
getAutoUpdateDelay(): number {
|
||||
const delayHours = this.configurationService.getValue<number>(AutoUpdateDelayConfigurationKey) ?? 2;
|
||||
return delayHours * 60 * 60 * 1000; // Convert hours to milliseconds
|
||||
}
|
||||
|
||||
private isFromTrustedPublisher(extension: IExtension): boolean {
|
||||
const trustedPublishers = this.productService.trustedExtensionPublishers;
|
||||
if (!trustedPublishers?.length) {
|
||||
|
||||
@@ -163,6 +163,7 @@ export interface IExtensionsWorkbenchService {
|
||||
getAutoUpdateValue(): AutoUpdateConfigurationValue;
|
||||
isAutoUpdateDelayed(extension: IExtension): boolean;
|
||||
getAutoUpdateDelayRemaining(extension: IExtension): number;
|
||||
getAutoUpdateDelay(): number;
|
||||
checkForUpdates(): Promise<void>;
|
||||
getExtensionRuntimeStatus(extension: IExtension): IExtensionRuntimeStatus | undefined;
|
||||
updateAll(): Promise<InstallExtensionResult[]>;
|
||||
|
||||
Reference in New Issue
Block a user