From f41aa5cc31bfd7a64e0f9b18193765f145af3bf8 Mon Sep 17 00:00:00 2001 From: CPTN Cosmo Date: Wed, 11 Feb 2026 16:43:31 +0100 Subject: [PATCH] fix: Improve context menu lifecycle management, update module version, and migrate repository links. --- module.json | 8 ++++---- scripts/.module.js.kate-swp | Bin 76 -> 0 bytes scripts/fear-tracker-app.js | 23 +++++++++++++++++++++-- scripts/module.js | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) delete mode 100644 scripts/.module.js.kate-swp diff --git a/module.json b/module.json index ae364dd..524a38d 100644 --- a/module.json +++ b/module.json @@ -1,7 +1,7 @@ { "id": "dh-feartrackerplus", "title": "Daggerheart Fear Tracker Plus", - "version": "2.0.1", + "version": "2.0.2", "compatibility": { "minimum": "13", "verified": "13" @@ -30,8 +30,8 @@ "styles": [ "styles/module.css" ], - "url": "https://github.com/cptn-cosmo/dh-feartrackerplus", - "manifest": "https://github.com/cptn-cosmo/dh-feartrackerplus/releases/latest/download/module.json", - "download": "https://github.com/cptn-cosmo/dh-feartrackerplus/releases/download/2.0.1/dh-feartrackerplus.zip", + "url": "https://git.geeks.gay/cosmo/dh-feartrackerplus", + "manifest": "https://git.geeks.gay/cosmo/dh-feartrackerplus/raw/branch/main/module.json", + "download": "https://git.geeks.gay/cosmo/dh-feartrackerplus/releases/download/2.0.2/dh-feartrackerplus.zip", "description": "Customizes the Fear Tracker for Daggerheart." } \ No newline at end of file diff --git a/scripts/.module.js.kate-swp b/scripts/.module.js.kate-swp deleted file mode 100644 index 8cc68b2f38cc91785ceafd60c900ff110ebb0252..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 76 zcmZQzU=Z?7EJ;-eE>A2_aLdd|RWQ;sU|?VnnPpwbDxnv0L&WZ}sduT9*CFoXYQaH3 QnHV7E2V!AY6s~|P0KX#-u>b%7 diff --git a/scripts/fear-tracker-app.js b/scripts/fear-tracker-app.js index 5e6d94f..9ac9fac 100644 --- a/scripts/fear-tracker-app.js +++ b/scripts/fear-tracker-app.js @@ -50,6 +50,21 @@ export class FearTrackerApp extends HandlebarsApplicationMixin(ApplicationV2) { this.instance.render({ force: true, position: pos }); } + // Removed render override to prevent destroying the context menu on re-render + // Since this.element persists, we don't need to recreate the listener. + + async close(options) { + if (this._contextMenu) { + try { + await this._contextMenu.close({ animate: false }); + } catch (e) { + // Ignore + } + this._contextMenu = null; + } + return super.close(options); + } + _onRender(context, options) { super._onRender(context, options); @@ -109,8 +124,12 @@ export class FearTrackerApp extends HandlebarsApplicationMixin(ApplicationV2) { this.#animateMaxFear(); // Context Menu for Unlocking (Right-click) + // Check if we already have a context menu instance. + // We only need one per application instance as long as this.element persists. + if (this._contextMenu) return; + // Use namespaced class and provide empty options to avoid system error - new foundry.applications.ux.ContextMenu(this.element, ".fear-tracker-window", [ + this._contextMenu = new foundry.applications.ux.ContextMenu(this.element, ".fear-tracker-window", [ { name: "Unlock Position", icon: '', @@ -129,7 +148,7 @@ export class FearTrackerApp extends HandlebarsApplicationMixin(ApplicationV2) { this.render(); } } - ], {}); + ], { jQuery: false }); } updateFearData(data) { diff --git a/scripts/module.js b/scripts/module.js index 907322e..b98250d 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -149,7 +149,7 @@ Hooks.once('init', () => { game.settings.register(MODULE_ID, 'showFearNumber', { name: 'Show Fear Number', - hint: 'Display the numerical value (e.g., 3 / 6) at the bottom.', + hint: 'Display the numerical value (e.g., 4 / 12) at the bottom.', scope: 'client', config: true, type: Boolean,