Sketch-Stickers icon indicating copy to clipboard operation
Sketch-Stickers copied to clipboard

Better handle libraries with same ID

Open iamhenry opened this issue 6 years ago • 14 comments

I must be doing something wrong. Here's what I've done.

  1. Duplicated a Library for testing purposes
  2. Added the Library to my Sketch Preferences
  3. Copied the snippet to generate one section !StickerSection @Section1 title: First section description: A description
  4. I get duplicate sections
  5. 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.

screen shot 2018-07-05 at 4 29 20 pm

iamhenry avatar Jul 05 '18 23:07 iamhenry

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?

romannurik avatar Jul 05 '18 23:07 romannurik

Just tried that and no luck. Here are some more screenshots for better clarity:

image image image

iamhenry avatar Jul 05 '18 23:07 iamhenry

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 :)

romannurik avatar Jul 16 '18 20:07 romannurik

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. 🤔

iamhenry avatar Jul 18 '18 17:07 iamhenry

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

romannurik avatar Jul 18 '18 17:07 romannurik

    "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```

iamhenry avatar Jul 18 '18 17:07 iamhenry

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?

romannurik avatar Jul 18 '18 22:07 romannurik

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?

iamhenry avatar Jul 18 '18 22:07 iamhenry

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. image

iamhenry avatar Jul 18 '18 22:07 iamhenry

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

iamhenry avatar Jul 18 '18 22:07 iamhenry

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 :-)

romannurik avatar Jul 18 '18 22:07 romannurik

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('');
});

romannurik avatar Jul 19 '18 03:07 romannurik

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.

tijmenvangurp avatar Feb 25 '19 16:02 tijmenvangurp

Thanks for the link!

romannurik avatar Feb 25 '19 16:02 romannurik