Sketch-Stickers
Sketch-Stickers copied to clipboard
Better handle libraries with same ID
I must be doing something wrong. Here's what I've done.
- Duplicated a Library for testing purposes
- Added the Library to my Sketch Preferences
- Copied the snippet to generate one section
!StickerSection @Section1 title: First section description: A description
- I get duplicate sections
- I also can't get rid of a section that I've deleted the library from in the preferences and the .sketch file but it still shows up. Not sure what's going on there.
I think there are some hard to reproduce bugs related to library indexing and caching. Try deleting the directory ~/Library/Caches/net.nurik.roman.sketch.stickers
and restarting Sketch?
Just tried that and no luck. Here are some more screenshots for better clarity:
Hey there, could you go to Plugins > Run Script, paste this, run it, and share the output?
let libraries = Array.from(NSApp.delegate().librariesController().libraries())
.filter(lib => !!lib.locationOnDisk() && !!lib.enabled())
.map(lib => String(lib.libraryID()));
log(libraries);
This should basically print out the library IDs for libraries on your computer. If there are two that are the same, I think I know what the problem is :)
With the new update I can't ever get the sections to show with the test file you provided. Any idea of whats going on?
I already deleted the files ~/Library/Caches/net.nurik.roman.sketch.stickers
and restarted Sketch too. 🤔
Hey there, could you run that script and share results? My guess is you have several libraries that have a single library ID, which the plugin doesn't currently handle very well
"F55B8C55-90F8-4303-99AA-167FDD09C007",
"7BA42C00-55A8-477E-9053-2D50DBA1BDC8",
"A3CF9057-669C-4784-AEEF-17730C21AEA6",
"D7943480-3D21-4624-B0C1-2C7FE92F30BD",
"94744881-09BD-42A6-A980-098844B57631",
"1249B1AF-D98C-4FDB-87C5-96510DB3B6FB",
"D7943480-3D21-4624-B0C1-2C7FE92F30BD",
"D7943480-3D21-4624-B0C1-2C7FE92F30BD"
)
Script executed in 0.020908s```
Yep, as I suspected there are several libraries with the ID D79...BD, currently Stickers can't differentiate between them and the latest version just picks one of them to show. I'm exploring better solutions for handling this but in the meantime you may want to make sure you indeed need all the libraries you have installed. I can update that script so you can see exactly which ones are conflicting if that helps?
You say say installed libraries, does that mean libraries that are in the Sketch preferences or just the library that has the syntax to make this plugin work?
Also, is there a way that the plugin can import an instance of the symbol instead of the entire artboard so that it can be used in other Sketch files? Currently I would have to create an instance of the symbol and tag that, but that can be very tedious.
Here's the bug I'm getting when trying add tags to artboards and they don't show up when using the plugin: https://www.dropbox.com/s/ev6wf9bcs95npj9/stickers-bug.mov?dl=0
Installed libraries, yes those that appear in the Libraries list in preferences, regardless of whether they have the metadata.
For importing an instance, you can just tag an instance of the symbol rather than the symbol itself :-)
Also, here's a script you can run to see which libraries you have installed + enabled that share an ID:
let libsById = {};
let libraries = Array.from(NSApp.delegate().librariesController().libraries())
.filter(lib => !!lib.locationOnDisk() && !!lib.enabled() && !!lib.libraryID())
.forEach(lib => {
let id = String(lib.libraryID());
libsById[id] = libsById[id] || [];
libsById[id].push(lib);
});
let dups = Object.values(libsById).filter(libs => libs.length > 1);
if (!dups.length) {
log('All good! None of your libraries share an ID');
return;
}
dups.forEach(libs => {
log('These libraries share an ID:');
libs.forEach(lib => log('> ' + lib.name()));
log('');
});
This plugin https://github.com/Ashung/Automate-Sketch/blob/master/readme.md
has a script called: Fix Library ID Conflict
basically every time you duplicate a file you get this issue.
I don't think this plugin necessarily should fix this. Maybe just add something to the readme, or provide helpful indication on how to solve this when it happens.
Thanks for the link!