pick up annotation changes

This commit is contained in:
Emiliano Heyns
2022-04-25 14:31:46 +02:00
parent afeade2bb3
commit 37a5a82404
2 changed files with 10 additions and 3 deletions

View File

@@ -664,7 +664,7 @@ notify('item-tag', (_action: any, _type: any, ids: any[], _extraData: any) => {
notify('item', (action: string, type: any, ids: any[], extraData: { [x: string]: { bbtCitekeyUpdate: any } }) => {
// prevents update loop -- see KeyManager.init()
log.debug('item', action, ids)
// log.debug('item', action, ids, Zotero.Items.get(ids).map(item => Zotero.Utilities.Internal.itemToExportFormat(item))) // eslint-disable-line @typescript-eslint/no-unsafe-return
if (action === 'modify') {
ids = ids.filter((id: string | number) => !extraData[id] || !extraData[id].bbtCitekeyUpdate)
if (!ids.length) return
@@ -676,8 +676,14 @@ notify('item', (action: string, type: any, ids: any[], extraData: { [x: string]:
// https://groups.google.com/forum/#!topic/zotero-dev/99wkhAk-jm0
const parentIDs = []
const items = action === 'delete' ? [] : Zotero.Items.get(ids).filter((item: ZoteroItem) => {
if (typeof item.parentID !== 'boolean') {
parentIDs.push(item.parentID)
if (item.isAttachment() || item.isNote()) {
const parentID = item.parentID
if (typeof parentID === 'number') parentIDs.push(parentID)
return false
}
if (item.isAnnotation()) {
const parentID = item.parentItem?.parentID
if (typeof parentID === 'number') parentIDs.push(parentID)
return false
}

1
typings/global.d.ts vendored
View File

@@ -49,6 +49,7 @@ interface ZoteroItem {
itemTypeID: number
libraryID: number
parentID: number
parentItem?: ZoteroItem
key: string
getField: (name: string, unformatted?: boolean, includeBaseMapped?: boolean) => string | number
setField: (name: string, value: string | number) => void