From 4a0b0e26c703b498720b28125675b94533562424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 14 Jul 2023 14:39:45 +0200 Subject: [PATCH] extensionUtils: Move isOutOfDate() into manager It hasn't been used anywhere else since the old prefs-tool stopped implementing its own extension loading. Part-of: --- js/misc/extensionUtils.js | 8 +------- js/ui/extensionSystem.js | 9 ++++++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/js/misc/extensionUtils.js b/js/misc/extensionUtils.js index 9642734d6..3ad912c78 100644 --- a/js/misc/extensionUtils.js +++ b/js/misc/extensionUtils.js @@ -1,8 +1,7 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported ExtensionState, ExtensionType, getCurrentExtension, getSettings, initTranslations, gettext, ngettext, pgettext, - openPrefs, isOutOfDate, serializeExtension, - deserializeExtension, setExtensionManager */ + openPrefs, serializeExtension, deserializeExtension, setExtensionManager */ // Common utils for the extension system and the extension // preferences tool @@ -242,11 +241,6 @@ function openPrefs() { } } -function isOutOfDate(extension) { - const [major] = Config.PACKAGE_VERSION.split('.'); - return !extension.metadata['shell-version'].some(v => v.startsWith(major)); -} - function serializeExtension(extension) { let obj = { ...extension.metadata }; diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js index 72b1bb476..abe98b574 100644 --- a/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js @@ -14,6 +14,8 @@ const FileUtils = imports.misc.fileUtils; const Main = imports.ui.main; const MessageTray = imports.ui.messageTray; +const Config = imports.misc.config; + const { ExtensionState, ExtensionType } = ExtensionUtils; const ENABLED_EXTENSIONS_KEY = 'enabled-extensions'; @@ -431,11 +433,16 @@ var ExtensionManager = class extends Signals.EventEmitter { return extension.metadata.version === version; } + _isOutOfDate(extension) { + const [major] = Config.PACKAGE_VERSION.split('.'); + return !extension.metadata['shell-version'].some(v => v.startsWith(major)); + } + async loadExtension(extension) { // Default to error, we set success as the last step extension.state = ExtensionState.ERROR; - if (this._checkVersion && ExtensionUtils.isOutOfDate(extension)) { + if (this._checkVersion && this._isOutOfDate(extension)) { extension.state = ExtensionState.OUT_OF_DATE; } else if (!this._canLoad(extension)) { this.logExtensionError(extension.uuid, new Error(