mgmeyers / obsidian-zotero-integration

Insert and import citations, bibliographies, notes, and PDF annotations from Zotero into Obsidian.
GNU General Public License v3.0
1.09k stars 55 forks source link

the lastExportDate is always 1/1/1970, leading to wrong extraction of newly added annotation #377

Open Youngerkind opened 4 months ago

Youngerkind commented 4 months ago

I have two template files borrowing from the internet. One of them is for extracting newly added annotations, which means that only those, whose date are newer than the literature's lastExportDate, will be exported.

However, every literature's lastExportDate in the Data Explorer is "1/1/1970 8:00:00 AM" at present. Thus, the script will export all annotations now.

(2024/09/09) FYI, I put the template file below.

{% set annots = annotations | filterby("date", "dateafter", lastImportDate) -%}
{% if annots.length > 0 %}
# Background
{% for an in annots -%}
{% if an.colorCategory == 'Yellow' -%}
{% if an.annotatedText -%}
"{{an.annotatedText}}" ([@{{citekey}}](zotero://open-pdf/library/items/{{an.attachment.itemKey}}?page={{an.page}}&annotation={{an.id}}))
{% endif %}
{%- if an.imageBaseName %}![[{{an.imageBaseName}}]]([@{{citekey}}](zotero://open-pdf/library/items/{{an.attachment.itemKey}}?page={{an.page}}&annotation={{an.id}}))
{% endif -%}
{{an.comment}}
{% endif %}
{%- endfor -%}
zeroYlin commented 3 months ago

I thought when a note is being exported, the Zotero Integration will write a date to the file's matadata in Zotero. But I not familiar with javascript, I don't know how to change the code.

I try to downgrade my Zotero7 to Zotero6, but it doesn't work

zeroYlin commented 2 months ago

That won't affect the template below, it can correctly import the note which being added later. I am not sure what exactly the lastImportDate is, it seems that it is independent from the lastExportDate in Data Explorer.

{% persist "annotations" %}
{% set newAnnotations = annotations | filterby("date", "dateafter", lastImportDate) %}
{% if newAnnotations.length > 0 %}

### Imported: {{importDate | format("YYYY-MM-DD h:mm a")}}

{% for a in newAnnotations %}
> {{a.annotatedText}}
{% endfor %}

{% endif %}
{% endpersist %}