@@ -91,11 +91,13 @@ export default {
9191 // Files & Media type:
9292 // `url` and `expiry_time` are constantly updated by Notion, so ignore these fields
9393 if ( property . type === "files" ) {
94- for ( const file of property . files ) {
94+ const modified = structuredClone ( property ) ;
95+ for ( const file of modified . files ) {
9596 if ( file . type === "file" ) {
9697 delete file . file ;
9798 }
9899 }
100+ return modified ;
99101 }
100102 return property ;
101103 } ,
@@ -153,34 +155,38 @@ export default {
153155
154156 for ( const propertyName of propertiesToCheck ) {
155157 const previousValue = structuredClone ( propertyValues [ page . id ] ?. [ propertyName ] ) ;
156- const currentValue = this . maybeRemoveFileSubItems ( page . properties [ propertyName ] ) ;
158+ // value used to compare and to save to this.db
159+ const currentValueToSave = this . maybeRemoveFileSubItems ( page . properties [ propertyName ] ) ;
160+ // (unmodified) value that should be emitted
161+ const currentValueToEmit = page . properties [ propertyName ] ;
157162
158163 const pageExistsInDB = propertyValues [ page . id ] != null ;
159- const propertyChanged = JSON . stringify ( previousValue ) !== JSON . stringify ( currentValue ) ;
164+ const propertyChanged =
165+ JSON . stringify ( previousValue ) !== JSON . stringify ( currentValueToSave ) ;
160166
161167 if ( pageExistsInDB && propertyChanged ) {
162168 propertyHasChanged = true ;
163169 propertyValues [ page . id ] = {
164170 ...propertyValues [ page . id ] ,
165- [ propertyName ] : currentValue ,
171+ [ propertyName ] : currentValueToSave ,
166172 } ;
167173 changes . push ( {
168174 property : propertyName ,
169175 previousValue,
170- currentValue,
176+ currentValue : currentValueToEmit ,
171177 } ) ;
172178 }
173179
174180 if ( ! pageExistsInDB ) {
175181 isNewPage = true ;
176182 propertyHasChanged = true ;
177183 propertyValues [ page . id ] = {
178- [ propertyName ] : currentValue ,
184+ [ propertyName ] : currentValueToSave ,
179185 } ;
180186 changes . push ( {
181187 property : propertyName ,
182188 previousValue,
183- currentValue,
189+ currentValue : currentValueToEmit ,
184190 } ) ;
185191 }
186192 }
0 commit comments