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

Bulk create/update #351

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DanielRunningen
Copy link

This is just a draft to get a really important feature addressed. It should close #246 and possibly resolves #269 as well.

I propose two things:

  • Simply loop through the items provided by Zotero and iterate over their creation. I removed the call to open the created notes, since that could get excessive.
  • Since highlighting multiple documents in Zotero only provides the "Create Literature Note(s)" option, simply allow this option to update notes that already exist. Typically I like to have everything call an update function, and then forward the request to create if the item doesn't exist, but the reverse should do fine.

Doing a bulk import with these changes does still trigger the Obsidian menu to choose attachments for some of the items, but I feel like this is unavoidable and any assumptions made during import could be the wrong ones, so this part of #269 might be unavoidable.

I tried not to touch too many files, since this is all reverse-engineered from the Obsidian console. I would be happy to add/improve these changes, but I'd need some tips on building the repository.

@DennisFriedl
Copy link

Two important features. Thanks for working on it

@DanielRunningen
Copy link
Author

DanielRunningen commented Jun 21, 2024

For folks who want to be able to use this without waiting for the full PR to be approved, here is my modified main.js as a zip file. It also includes the date fix from my other PR.

To use it:

  • Download and unzip the file (it should just be the one file).
  • Place in your workspace under .obsidian/plugins/zotlit/. It will replace the main.js that's already there.
  • Either re-launch Obsidian or reload the ZotLit plugin.

Warning

I can't guarantee that this won't break something, so if you run into trouble with it, or suddenly don't trust me as a stranger on the internet, you can uninstall ZotLit as a plugin from Obsidian and re-install it. Your templates should remain unaffected.

Edit: clarifications

@dentistfrankchen
Copy link

dentistfrankchen commented Jan 12, 2025

After changing the main.js, it is still not working...
Uploading image.png…
Maybe the logic here is buggy?

@dentistfrankchen
Copy link

For my case, I changed the following code in main.js:
let { libraryID: r, id: n } = e.items[0],
[o] = await this.plugin.databaseAPI.getItems([[n, r]]);
if (!o) {
new wn.Notice("Item not found: " + n);
return;
}
let i = await this.plugin.noteFeatures.createNoteForDocItemFull(o);
await this.plugin.app.workspace.openLinkText(i, "", !1, { active: !0 });

to the following code :

for (const item of e.items) {
let { libraryID: r, id: n } = item; // Destructure assignment
const [o] = await this.plugin.databaseAPI.getItems([[n, r]]); // Retrieve the item from the database
if (!o) {
new wn.Notice("Item not found: " + n); // Notify that the item was not found
continue; // If not found, skip this item and continue to the next
}
await this.plugin.noteFeatures.createNoteForDocItemFull(o); // Create a note for the item
// Do not open the link here
}

This works for multiple import.
However I am not fluent with ts, I hope you guys can implement this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants