cs96and / FoundryVTT-damage-log

FoundryVTT module to report all damage and healing to a separate chat tab
MIT License
9 stars 9 forks source link

Add handling for chat not being loaded #26

Closed Leondthurrell closed 1 year ago

Leondthurrell commented 1 year ago

Issue
On loading Foundry, before chat loads, Throws This exception:

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'style')
[Detected 1 package: damage-log]
    at VM32931 damage-log.js:564:50
    at new Promise (<anonymous>)
    at DamageLog._onRenderChatMessage (VM32931 damage-log.js:560:4)
    at #call (foundry.js:724:20)
    at Hooks.call (foundry.js:706:38)
    at ChatMessage.getHTML (foundry.js:18091:11)
    at async ChatLog._renderBatch (foundry.js:73587:21)
    at async ChatLog._renderInner (foundry.js:73556:5)
    at async ChatLog._render (foundry.js:5073:19)
    at async ChatLog._render (foundry.js:59859:5)
    at async ChatLog._render (foundry.js:73547:5)
    at async Promise.all (index 2)

Issue caused by
Not being able get the rollsNotification element as it hasn't loaded yet

|564|     document.getElementById("rollsNotification").style.display = "none";

Suggested fix
Change line 563 to check if chat is loaded

Original:

|563|     if (flags.preventRollsNotification)

Suggested Change:

|563|    if (flags.preventRollsNotification && document.getElementById("rollsNotification"))
cs96and commented 1 year ago

Fixed in 1.8.4, thanks for the Pull Request!