Skip to content

Commit

Permalink
Release 1.0.0-15
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Sep 21, 2023
1 parent 4c6aaba commit 542ed80
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zotero-actions-tags",
"version": "1.0.0-14",
"version": "1.0.0-15",
"description": "Action it, tag it, sorted.",
"config": {
"addonName": "Actions and Tags for Zotero",
Expand Down
4 changes: 2 additions & 2 deletions src/modules/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function initMenu() {
function buildItemMenu(win: Window) {
const doc = win.document;
const popup = doc.querySelector(
`#${config.addonRef}-itemPopup`
`#${config.addonRef}-itemPopup`,
) as XUL.MenuPopup;
// Remove all children in popup
while (popup.firstChild) {
Expand Down Expand Up @@ -62,7 +62,7 @@ function buildItemMenu(win: Window) {
};
}),
},
popup
popup,
);
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/modules/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function initNotifierObserver() {
event: string,
type: string,
ids: number[] | string[],
extraData: { [key: string]: any }
extraData: { [key: string]: any },
) => {
if (!addon?.data.alive) {
Zotero.Notifier.unregisterObserver(notifierID);
Expand All @@ -35,63 +35,63 @@ async function onNotify(
event: string,
type: string,
ids: Array<string | number>,
extraData: { [key: string]: any }
extraData: { [key: string]: any },
) {
// You can add your code to the corresponding notify type
ztoolkit.log("notify", event, type, ids, extraData);
if (event === "open" && type === "file") {
const parentItems = Zotero.Items.getTopLevel(
Zotero.Items.get(ids as number[])
Zotero.Items.get(ids as number[]),
);
for (const item of parentItems) {
await addon.api.actionManager.dispatchActionByEvent(
ActionEventTypes.openFile,
{
itemID: item.id,
}
},
);
}
return;
}
if (event === "add" && type === "item") {
const items = Zotero.Items.get(ids as number[]).filter(
(item) => !(item instanceof Zotero.FeedItem)
(item) => !(item instanceof Zotero.FeedItem),
);
for (const item of items) {
if (item.isRegularItem()) {
await addon.api.actionManager.dispatchActionByEvent(
ActionEventTypes.createItem,
{
itemID: item.id,
}
},
);
} else if (item.isAnnotation()) {
await addon.api.actionManager.dispatchActionByEvent(
ActionEventTypes.createAnnotation,
{
itemID: item.id,
}
},
);
const parentItem = Zotero.Items.getTopLevel([item])[0];
await addon.api.actionManager.dispatchActionByEvent(
ActionEventTypes.appendAnnotation,
{
itemID: parentItem.id,
}
},
);
} else if (item.isNote()) {
await addon.api.actionManager.dispatchActionByEvent(
ActionEventTypes.createNote,
{
itemID: item.id,
}
},
);
const parentItem = Zotero.Items.getTopLevel([item])[0];
await addon.api.actionManager.dispatchActionByEvent(
ActionEventTypes.appendNote,
{
itemID: parentItem.id,
}
},
);
}
}
Expand All @@ -106,14 +106,14 @@ async function onNotify(
.map((id) => addon.data.tabStatus.get(id as string))
.filter((id) => id);
const parentItems = Zotero.Items.getTopLevel(
Zotero.Items.get(itemIDs as number[])
Zotero.Items.get(itemIDs as number[]),
);
for (const item of parentItems) {
await addon.api.actionManager.dispatchActionByEvent(
ActionEventTypes.closeTab,
{
itemID: item.id,
}
},
);
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function initActions() {
addon.data.actions.map = new ztoolkit.LargePref(
`${config.prefsPrefix}.rules`,
`${config.prefsPrefix}.rules.`,
"parser"
"parser",
).asMapLike() as ActionMap;
if (!getPref("rulesInit")) {
for (const key of defaultActions.keys()) {
Expand Down Expand Up @@ -140,7 +140,7 @@ async function applyAction(rule: ActionData, data: ActionDataData) {
item?.removeTag(tag);
}
message = `Remove tag ${tags.join(",")} from item ${item?.getField(
"title"
"title",
)}`;
break;
}
Expand All @@ -153,7 +153,7 @@ async function applyAction(rule: ActionData, data: ActionDataData) {
}
}
message = `Toggle tag ${tags.join(",")} to item ${item?.getField(
"title"
"title",
)}`;
break;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ async function applyAction(rule: ActionData, data: ActionDataData) {
function getActions(): Record<string, ActionData>;
function getActions(key: string): ActionData | undefined;
function getActions(
key?: string
key?: string,
): Record<string, ActionData> | ActionData | undefined {
if (!key) {
const map = addon.data.actions.map;
Expand Down
4 changes: 2 additions & 2 deletions update-beta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"zoterotag@euclpts.com": {
"updates": [
{
"version": "1.0.0-14",
"update_link": "https://github.com/windingwind/zotero-actions-tags/releases/download/v1.0.0-14/zotero-actions-tags.xpi",
"version": "1.0.0-15",
"update_link": "https://github.com/windingwind/zotero-actions-tags/releases/download/v1.0.0-15/zotero-actions-tags.xpi",
"applications": {
"zotero": {
"strict_min_version": "6.999"
Expand Down

0 comments on commit 542ed80

Please sign in to comment.