Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handle libraries with same ID #9

Open
iamhenry opened this issue Jul 5, 2018 · 14 comments
Open

Better handle libraries with same ID #9

iamhenry opened this issue Jul 5, 2018 · 14 comments
Labels
bug Something isn't working

Comments

@iamhenry
Copy link

iamhenry commented Jul 5, 2018

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

@romannurik
Copy link
Owner

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?

@iamhenry
Copy link
Author

iamhenry commented Jul 5, 2018

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

image
image
image

@romannurik
Copy link
Owner

romannurik commented Jul 16, 2018

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

@iamhenry
Copy link
Author

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

@romannurik
Copy link
Owner

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

@iamhenry
Copy link
Author

iamhenry commented Jul 18, 2018

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

@romannurik
Copy link
Owner

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?

@iamhenry
Copy link
Author

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
Copy link
Author

iamhenry commented Jul 18, 2018

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
Copy link
Author

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

@romannurik
Copy link
Owner

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
Copy link
Owner

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 romannurik changed the title Duplicate Sections Better handle libraries with same ID Jul 30, 2018
@romannurik romannurik added the bug Something isn't working label Oct 8, 2018
@tijmenvangurp
Copy link

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.

@romannurik
Copy link
Owner

Thanks for the link!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants