Larkinabout / fvtt-token-action-hud-core

Token Action HUD is a repositionable HUD of actions for a selected token.
14 stars 22 forks source link

[BUG] Errors for players that have an "Observer" permission for a token #7

Closed Solidor777 closed 1 year ago

Solidor777 commented 1 year ago

Describe the bug When a player in my game has an "Observer" permission for a token, they always get asserts on startup, or when the token data is updated.

I was able to trace this to the _updateHud() function. Modifying it to be as below fixes the problem.

 async _updateHud() {
        Logger.debug('Updating hud...')
        const controlledTokens = this.tokens?.controlled.filter((token) => token.isOwner);
        const character = this._getCharacter(controlledTokens)

        const multipleTokens = controlledTokens.length > 1 && !character

        if (((!character?.actor || !character.actor.isOwner) && !multipleTokens) || !this.isHudEnabled()) {
            this.close()
            return
        }

        this.actionList = await this.actionHandler.buildActionList(character)

        this.rendering = true
        this.render(true)
        Logger.debug('Hud updated')
}
Larkinabout commented 1 year ago

Hi @Solidor777, will you post the error message, so I can have a look over it please. There is a separate function for checking ownership and validity, it's also not erroring on my test of an Observer role, so I'd like to investigate further.

Solidor777 commented 1 year ago

I reverted my changes today and reinstalled the module so I could get the message and a video of the error for you... and it didn't happen.

Not sure what changed. Maybe there were some stale settings? But so far everything seems to be working without error now.

Larkinabout commented 1 year ago

New release has just dropped. I'll close this issue assuming it's resolved itself, but let me know if it recurs and I'll open it back up.