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

[Bug] In script mode, sometimes the selected item is given null. #324

Closed
2 tasks done
454116278 opened this issue May 7, 2024 · 2 comments
Closed
2 tasks done

[Bug] In script mode, sometimes the selected item is given null. #324

454116278 opened this issue May 7, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@454116278
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Are you using the latest Zotero and the latest plugin?

  • I have confirmed I'm using the latest Zotero and the latest plugin

Environment

  • OS: WIN 10 X64
  • Zotero Version: 7.0.0-beta.77+adaa61f2c(64-bit)
  • Plugin Version: 1.0.0-beta.39

Describe the bug

see the code from line 195 in actions.ts.

async function applyAction(action: ActionData, args: ActionArgs) {
const item =
(Zotero.Items.get(args.itemID || -1) as Zotero.Item | false) || null;
// If the item is not found and the operation is not script, early return.
if (action.operation !== ActionOperationTypes.script && !item) {
return false;
}

// if operation == script and item == null ,here dont return false.
// please check it is right or not.

Debug Output

I always get item == null in my script.

Anything else?

No response

@454116278 454116278 added the bug Something isn't working label May 7, 2024
@454116278
Copy link
Author

image
const now = new Date();
if(!item) return ${now} 空条目出现;

@454116278
Copy link
Author

I have debugged the codes, find out the dispatchActionByKey is called twice.
// await addon.api.actionManager.dispatchActionByKey(key, {
// itemIDs,
// collectionID: collection?.id,
// triggerType: "menu",
// });
// Trigger action for each item
for (const itemID of itemIDs) {
await addon.api.actionManager.dispatchActionByKey(key, {
itemID,
collectionID: collection?.id,
triggerType: "menu",
});
}

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

2 participants