fantasycalendar / FoundryVTT-Tagger

Other
6 stars 4 forks source link

[BUG] Incorrect handling of application rendering hooks #34

Closed dev7355608 closed 2 months ago

dev7355608 commented 3 months ago

Describe the bug https://github.com/fantasycalendar/FoundryVTT-Tagger/blob/197e59169b700aaf330451a516c216eebad227cf/scripts/module.js#L382-L390

You cannot expect the class the have a name or the name to contain the name of the base class. For example Vision 5e's TokenConfig extension doesn't have a name: https://github.com/dev7355608/vision-5e/blob/main/scripts/token-config.mjs. And so currently Tagger options don't show up in the token config at all if Vision 5e is enabled. (The reason that the Vision 5e TokenConfig class doesn't have a name is that in V12 no render* hooks is triggered for a nameless class in the inheritance chain.)

I recommend removing _handleRenderFormApplication and registering the app render hooks like so:

const configHandlers = {
  "TokenConfig": "_handleTokenConfig",
  "TileConfig": "_handleTileConfig",
  "DrawingConfig": "_handleDrawingConfig",
  "AmbientLightConfig": "_handleAmbientLightConfig", // v9
  "LightConfig": "_handleGenericConfig", // v8
  "WallConfig": "_handleGenericConfig",
  "AmbientSoundConfig": "_handleGenericConfig",
  "MeasuredTemplateConfig": "_handleGenericConfig",
  "NoteConfig": "_handleGenericConfig"
}

for (const [configName, configHandler] of Object.entries(configHandlers)) {
  Hooks.on(`render${configName}`, (app, html) => TaggerConfig[configHandler](app, html, true));
}

To Reproduce Steps to reproduce the behavior:

  1. Enable Vision 5e.
  2. Open Token config.
  3. Look for Tagger options in the config.

Expected behavior Expect Tagger options in the Token config.

Setup:

Active modules:

Haxxer commented 2 months ago

Thank you, added in 1.5.0!