Roll20APIScripts icon indicating copy to clipboard operation
Roll20APIScripts copied to clipboard

[InspirationTracker] Dragging a token that does not represent a character causes an error

Open RaaviArda opened this issue 6 years ago • 0 comments

When dragging a token that doesn't have "represents" property set to the game board the API console outputs an error - invalid parameter (empty) for getAttrByName(). This is caused by function handleAddToken: handleAddToken = (obj) => { setStatusmarker(obj, (getAttrByName(obj.get('represents'), 'inspiration', 'current') === 'on')); },

There is no validation against undefined or empty "represents". Simplest fix:

handleAddToken = (obj) => {
	if (typeof obj.get('represents') != 'undefined' && obj.get('represents').length > 0) {
		setStatusmarker(obj, (getAttrByName(obj.get('represents'), 'inspiration', 'current') === 'on'));
	}
},

RaaviArda avatar Feb 16 '19 01:02 RaaviArda