Skip to content

Commit 35a9fd6

Browse files
committed
Always sync formula and relation properties
1 parent 3887077 commit 35a9fd6

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

plugins/notion/src/api.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ export const supportedCMSTypeByNotionPropertyType = {
8585
formula: ["string", "number", "boolean", "date", "dateTime", "link", "color"],
8686
} satisfies Partial<Record<NotionProperty["type"], readonly VirtualFieldType[]>>
8787

88+
/**
89+
* These Notion property types are always re-synced even when the page's `last_edited_time` is unchanged.
90+
* Formula results and relation values can change without the last edited time being updated in Notion.
91+
*/
92+
export const alwaysSyncedPropertyTypes = ["formula", "relation"]
93+
8894
// Naive implementation to be authenticated, a token could be expired.
8995
// For simplicity we just close the plugin and clear storage in that case.
9096
export function isAuthenticated() {

plugins/notion/src/data.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import {
44
type FieldDataEntryInput,
55
type FieldDataInput,
66
framer,
7-
ManagedCollection,
7+
type ManagedCollection,
88
type ManagedCollectionFieldInput,
99
} from "framer-plugin"
1010
import pLimit from "p-limit"
1111
import * as v from "valibot"
1212
import {
13+
alwaysSyncedPropertyTypes,
1314
assertFieldTypeMatchesPropertyType,
1415
type FieldInfo,
1516
getDatabase,
@@ -230,8 +231,10 @@ export async function syncCollection(
230231
const field = fieldsById.get(property.id)
231232
if (!field) continue
232233

233-
// Skip field value if the item has not changed and the field type has not changed
234-
if (isUnchanged && !updatedFieldIds.has(field.id)) continue
234+
// Skip field value if the item has not changed and the field type has not changed.
235+
// Always synced property types are never skipped.
236+
if (isUnchanged && !updatedFieldIds.has(field.id) && !alwaysSyncedPropertyTypes.includes(property.type))
237+
continue
235238

236239
const fieldEntry = getFieldDataEntryForProperty(property, field)
237240
if (fieldEntry) {

0 commit comments

Comments
 (0)