From 14a209a45ae34ac1f72e6eeaaa3d41abce80a4dd Mon Sep 17 00:00:00 2001 From: Romain Vigier Date: Fri, 7 Aug 2020 13:30:55 +0200 Subject: [PATCH] Don't remove keybinding if it wasn't added --- src/modules/TimerOndemand.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/modules/TimerOndemand.js b/src/modules/TimerOndemand.js index e80695a..78e7232 100644 --- a/src/modules/TimerOndemand.js +++ b/src/modules/TimerOndemand.js @@ -41,6 +41,7 @@ var TimerOndemand = class { constructor() { this._button = null; + this._previousKeybinding = null; this._ondemandKeybindingConnect = null; this._ondemandButtonPlacementConnect = null; } @@ -99,6 +100,7 @@ var TimerOndemand = class { _addKeybinding() { + this._previousKeybinding = e.settingsManager.ondemandKeybinding; if (!e.settingsManager.ondemandKeybinding) return; logDebug('Adding On-demand Timer keybinding...'); @@ -113,9 +115,11 @@ var TimerOndemand = class { } _removeKeybinding() { - logDebug('Removing On-demand Timer keybinding...'); - main.wm.removeKeybinding('nightthemeswitcher-ondemand-keybinding'); - logDebug('Removed On-demand Timer keybinding.'); + if (this._previousKeybinding) { + logDebug('Removing On-demand Timer keybinding...'); + main.wm.removeKeybinding('nightthemeswitcher-ondemand-keybinding'); + logDebug('Removed On-demand Timer keybinding.'); + } } _addButton() {