From b01a53da95f30ee0737292c61be01d919c558868 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Thu, 1 Aug 2024 05:57:04 +0200 Subject: [PATCH] :fire: Remove duplicated code --- prefs.js | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/prefs.js b/prefs.js index 7d75c34..419ac84 100644 --- a/prefs.js +++ b/prefs.js @@ -46,23 +46,6 @@ import TVGlitch from './src/effects/TVGlitch.js'; import Wisps from './src/effects/Wisps.js'; import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; -import * as Config from 'resource:///org/gnome/Shell/Extensions/js/misc/config.js'; - -const [GS_MAJOR, GS_MINOR] = Config.PACKAGE_VERSION.split('.').map(toNumericVersion); - -// Returns the given argument, except for "alpha", "beta", and "rc". In these cases -3, -// -2, and -1 are returned respectively. -function toNumericVersion(x) { - switch (x) { - case 'alpha': - return -3; - case 'beta': - return -2; - case 'rc': - return -1; - } - return x; -} // Currently, the extension supports only one set of UI files. In the past, there were // three different sets for GTK3, GTK4, and Adwaita. This method returns the name of the @@ -71,21 +54,6 @@ function getUIDir() { return 'adw'; } -// This method returns true if the current GNOME Shell version is at least as high as the -// given arguments. Supports "alpha" and "beta" for the minor version number. -function shellVersionIsAtLeast(major, minor) { - if (GS_MAJOR > major) { - return true; - } - - if (GS_MAJOR == major) { - return GS_MINOR >= toNumericVersion(minor); - } - - return false; -} - - ////////////////////////////////////////////////////////////////////////////////////////// // The preferences dialog is organized in pages, each of which is loaded from a // // separate ui file. There's one page with general options, all other paged are loaded // @@ -231,7 +199,7 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences { // Now add all the rows. this._ALL_EFFECTS.forEach(effect => { const [minMajor, minMinor] = effect.getMinShellVersion(); - if (shellVersionIsAtLeast(minMajor, minMinor)) { + if (utils.shellVersionIsAtLeast(minMajor, minMinor)) { const uiFile = `/ui/${getUIDir()}/${effect.getNick()}.ui`; @@ -691,7 +659,7 @@ GitHub: https://github.com/spon // Connect all effect settings. this._ALL_EFFECTS.forEach(effect => { const [minMajor, minMinor] = effect.getMinShellVersion(); - if (shellVersionIsAtLeast(minMajor, minMinor)) { + if (utils.shellVersionIsAtLeast(minMajor, minMinor)) { this.bindSwitch(`${effect.getNick()}-enable-effect`); effect.bindPreferences(this); }