Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugins/notion/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export const supportedCMSTypeByNotionPropertyType = {
formula: ["string", "number", "boolean", "date", "dateTime", "link", "color"],
} satisfies Partial<Record<NotionProperty["type"], readonly VirtualFieldType[]>>

/**
* These Notion property types are always re-synced even when the page's `last_edited_time` is unchanged.
* Formula results and relation values can change without the last edited time being updated in Notion.
*/
export const alwaysSyncedPropertyTypes = ["formula", "relation"]

// Naive implementation to be authenticated, a token could be expired.
// For simplicity we just close the plugin and clear storage in that case.
export function isAuthenticated() {
Expand Down
14 changes: 11 additions & 3 deletions plugins/notion/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import {
type FieldDataEntryInput,
type FieldDataInput,
framer,
ManagedCollection,
type ManagedCollection,
type ManagedCollectionFieldInput,
} from "framer-plugin"
import pLimit from "p-limit"
import * as v from "valibot"
import {
alwaysSyncedPropertyTypes,
assertFieldTypeMatchesPropertyType,
type FieldInfo,
getDatabase,
Expand Down Expand Up @@ -230,8 +231,15 @@ export async function syncCollection(
const field = fieldsById.get(property.id)
if (!field) continue

// Skip field value if the item has not changed and the field type has not changed
if (isUnchanged && !updatedFieldIds.has(field.id)) continue
// Skip field value if the item has not changed and the field type has not changed.
// Always synced property types are never skipped.
if (
isUnchanged &&
!updatedFieldIds.has(field.id) &&
!alwaysSyncedPropertyTypes.includes(property.type)
) {
continue
}

const fieldEntry = getFieldDataEntryForProperty(property, field)
if (fieldEntry) {
Expand Down
Loading