beta91: deleteing collection before deleting item yields parentCollection.removeItem is not a function

61 views
Skip to first unread message

Emiliano Heyns

unread,
Jun 22, 2024, 6:24:14 PMJun 22
to zotero-dev
This order works:

let items = await Zotero.Items.getAll(Zotero.Libraries.userLibraryID, false, true, true)
    while (items.length) {
      const chunk = items.splice(0, 100)
      await Zotero.Items.erase(chunk)
    }

    await Zotero.Items.emptyTrash(Zotero.Libraries.userLibraryID)

    for (const collection of (Zotero.Collections.getByLibrary(Zotero.Libraries.userLibraryID, true) || [])) {
      await collection.eraseTx()
    }

this order fails:

for (const collection of (Zotero.Collections.getByLibrary(Zotero.Libraries.userLibraryID, true) || [])) {
      await collection.eraseTx()
    }


for (const collection of (Zotero.Collections.getByLibrary(Zotero.Libraries.userLibraryID, true) || [])) {
      await collection.eraseTx()
    }

Dan Stillman

unread,
Jun 22, 2024, 6:31:00 PMJun 22
to zoter...@googlegroups.com
On 6/22/24 6:24 PM, Emiliano Heyns wrote:
> this order fails:
>
> for (const collection of
> (Zotero.Collections.getByLibrary(Zotero.Libraries.userLibraryID, true)
> || [])) {
>       await collection.eraseTx()
>     }
>
>
> for (const collection of
> (Zotero.Collections.getByLibrary(Zotero.Libraries.userLibraryID, true)
> || [])) {
>       await collection.eraseTx()
>     }

I don't think think this is what you meant to write?

Emiliano Heyns

unread,
Jun 22, 2024, 7:28:52 PMJun 22
to zotero-dev
Oops.


This order works:

  let items = await Zotero.Items.getAll(Zotero.Libraries.userLibraryID, false, true, true)
  while (items.length) {
    const chunk = items.splice(0, 100)
    await Zotero.Items.erase(chunk)
  }

  await Zotero.Items.emptyTrash(Zotero.Libraries.userLibraryID)

  for (const collection of (Zotero.Collections.getByLibrary(Zotero.Libraries.userLibraryID, true) || [])) {
    await collection.eraseTx()
  }

this order fails:

  for (const collection of (Zotero.Collections.getByLibrary(Zotero.Libraries.userLibraryID, true) || [])) {
    await collection.eraseTx()
  }

  let items = await Zotero.Items.getAll(Zotero.Libraries.userLibraryID, false, true, true)
  while (items.length) {
    const chunk = items.splice(0, 100)
    await Zotero.Items.erase(chunk)
  }

  await Zotero.Items.emptyTrash(Zotero.Libraries.userLibraryID)

Dan Stillman

unread,
Jul 4, 2024, 7:08:12 AM (12 days ago) Jul 4
to zoter...@googlegroups.com
On 6/22/24 7:28 PM, Emiliano Heyns wrote:
> this order fails:
>
>   for (const collection of
> (Zotero.Collections.getByLibrary(Zotero.Libraries.userLibraryID, true)
> || [])) {
>     await collection.eraseTx()
>   }
>
>   let items = await
> Zotero.Items.getAll(Zotero.Libraries.userLibraryID, false, true, true)
>   while (items.length) {
>     const chunk = items.splice(0, 100)
>     await Zotero.Items.erase(chunk)
>   }
>
>   await Zotero.Items.emptyTrash(Zotero.Libraries.userLibraryID)

That works fine for me.
Reply all
Reply to author
Forward
0 new messages