From b8db5daa12e39066404dca520275d05d0d47c36b Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 17 Jan 2022 21:30:54 +0100 Subject: [PATCH] :wrench: Use try/catch for more robust import --- extension.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/extension.js b/extension.js index c8dcc3b..86c340e 100644 --- a/extension.js +++ b/extension.js @@ -13,16 +13,22 @@ 'use strict'; -const ExtensionUtils = imports.misc.extensionUtils; -const Me = imports.misc.extensionUtils.getCurrentExtension(); -const utils = Me.imports.src.utils; - const {Clutter, Gio, Meta} = imports.gi; const Workspace = imports.ui.workspace.Workspace; const WindowManager = imports.ui.windowManager.WindowManager; -const WindowPreview = - utils.shellVersionIsAtLeast(3, 38) ? imports.ui.windowPreview.WindowPreview : null; + +// The WindowPreview class is only available on GNOME Shell 3.38+; +let WindowPreview = null; +try { + WindowPreview = imports.ui.windowPreview.WindowPreview; +} catch (error) { + // Nothing to be done, we are on GNOME Shell 3.36. +} + +const ExtensionUtils = imports.misc.extensionUtils; +const Me = imports.misc.extensionUtils.getCurrentExtension(); +const utils = Me.imports.src.utils; // New effects must be registered here and in prefs.js. const ALL_EFFECTS = [