[BUG] Don't change valid note icons
toastygm opened this issue · 2 comments
Describe the bug
In the function getIconForNote()
(scene-packer.js:2411
), if Automatic Journal Icon Numbers (AJIN) was used to create an icon for the note, but if AJIN is now not active, you set the icon to the default book icon.
PROPOSAL: If the icon points to a valid file, you should simply leave it alone, regardless of whether AJIN is present or not.
I use AJIN to create nice note pins on my scenes. But I don't want to force users of my module to have AJIN installed to use my module. I want to use it myself to create the pins, but after that users of my modules should be able to see those nice note icons without having to have AJIN installed.
Also: Please note that AJIN allows you to change the default directory to place icons SVG files. Your code specifies "modules/journal-icon-numbers/
", but in fact the default is "upload/journal-icon-numbers
", and that value is configurable, so icons created by AJIN might have any path at all; you cannot make any assumptions about the path.
In my case, I use the path modules/cgi-olokand/assets/noteicons
; so as you can see it might be virtually anything.
Versions (please complete the following information):
- Foundry VTT 0.8.9
- HarnMaster 1.2.21
- Scene Packer 2.3.9
To Reproduce
Steps to reproduce the behavior:
- Activate Automatic Journal Icon Numbers
- Change the default location to a folder under your module
- Create a new scene (or use existing scene) and create notes using AJIN
- Pack Scene
- Create new world
- Activate your module, but don't activate AJIN.
All notes on the scene will now be book icons rather than the original AJIN icons.
Expected behavior
If the icon exists, regardless of whether AJIN is active or not, leave the icon alone.
I suggest modifying getIconForNote()
to be the following:
function getIconForNote(note) {
// Test the icon exists and replace it if it doesn't
$.get(icon).fail(() => icon = 'icons/svg/book.svg');
return icon;
}
This fixes the problem (I've tested it).