Skip to content

Conversation

@madebyisaacr
Copy link
Collaborator

@madebyisaacr madebyisaacr commented Sep 4, 2025

Description

This pull request optimizes re-syncing collections in the Notion plugin by only including field values if the item has been changed since the last sync or the field type has changed. This eliminates one API call per image or file on unchanged items.

When re-syncing a database with 50 images and no changes in Notion, it now takes about 1.5-2 seconds to sync compared to 5-8 seconds before.

Screen.Recording.2025-09-04.at.8.27.32.PM.mov

Testing

Here's a database with 50 images:
https://www.notion.so/framer/264adf6e8c968083994bc1de22c55953?v=264adf6e8c96808aa97d000c2f134e07&source=copy_link

  • Sync the database
  • Add, remove, and modify items and make sure the changes are synced correctly
  • Change field types

@madebyisaacr madebyisaacr marked this pull request as ready for review September 5, 2025 01:08
Copy link
Contributor

@kaloyanvi kaloyanvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, left a comment about using simpler data structure for storing.

Copy link
Contributor

@kaloyanvi kaloyanvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-approving, nice work! We should address this comment though.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment @cursor review or bugbot run to trigger another review on this PR

}

if (fieldsById.has(pageCoverProperty.id)) {
if (fieldsById.has(pageCoverProperty.id) && !isUnchanged) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Field Type Changes Missed in Sync

The syncCollection function's optimization for unchanged items doesn't fully apply to page content and cover fields. It skips processing these fields if the item hasn't changed, even if their field type has been modified or they are newly added. This can lead to missing data for these fields.

Fix in Cursor Fix in Web

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch here. The field type of content and cover can't be changed, but was broken when you would sync with content or cover disabled then enable them and sync again. Fixed that.

@madebyisaacr
Copy link
Collaborator Author

Fixed another bug and added the optimization you suggested @kaloyanvi. Ready for QA now.

@kaloyanvi
Copy link
Contributor

✅ QA, nice one!

@kaloyanvi
Copy link
Contributor

Btw, for things like this we should start adding tests. We should be able to simulate all cases to update / not update based on item / field with some mock data.

@madebyisaacr madebyisaacr added this pull request to the merge queue Sep 15, 2025
Merged via the queue into main with commit 5e2e0e7 Sep 15, 2025
7 of 9 checks passed
@madebyisaacr madebyisaacr deleted the notion-optimize-files branch September 15, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants