Skip to content

Commit deb2971

Browse files
authored
Merging pull request #18127
1 parent 8b49d21 commit deb2971

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

components/notion/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/notion",
3-
"version": "0.9.0",
3+
"version": "0.9.1",
44
"description": "Pipedream Notion Components",
55
"main": "notion.app.mjs",
66
"keywords": [

components/notion/sources/updated-page/updated-page.mjs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default {
99
key: "notion-updated-page",
1010
name: "New or Updated Page in Database (By Property)",
1111
description: "Emit new event when a page is created or updated in the selected database. [See the documentation](https://developers.notion.com/reference/page)",
12-
version: "0.1.10",
12+
version: "0.1.11",
1313
type: "source",
1414
dedupe: "unique",
1515
props: {
@@ -166,14 +166,17 @@ export default {
166166
break;
167167
}
168168

169+
// Check if this is a new page first
170+
const pageExistsInDB = propertyValues[page.id] != null;
171+
isNewPage = !pageExistsInDB;
172+
169173
for (const propertyName of propertiesToCheck) {
170174
const previousValue = structuredClone(propertyValues[page.id]?.[propertyName]);
171175
// value used to compare and to save to this.db
172176
const currentValueToSave = this._maybeRemoveFileSubItems(page.properties[propertyName]);
173177
// (unmodified) value that should be emitted
174178
const currentValueToEmit = page.properties[propertyName];
175179

176-
const pageExistsInDB = propertyValues[page.id] != null;
177180
const propertyChanged =
178181
JSON.stringify(previousValue) !== JSON.stringify(currentValueToSave);
179182

@@ -191,25 +194,28 @@ export default {
191194
}
192195

193196
if (!pageExistsInDB) {
194-
isNewPage = true;
195-
propertyHasChanged = true;
196-
propertyValues[page.id] = {
197-
[propertyName]: currentValueToSave,
198-
};
199-
changes.push({
200-
property: propertyName,
201-
previousValue,
202-
currentValue: currentValueToEmit,
203-
});
204-
}
205-
}
197+
// For new pages, always track the properties
198+
if (!propertyValues[page.id]) {
199+
propertyValues[page.id] = {};
200+
}
201+
propertyValues[page.id][propertyName] = currentValueToSave;
206202

207-
if (isNewPage && !this.includeNewPages) {
208-
console.log(`Ignoring new page: ${page.id}`);
209-
continue;
203+
// Only mark as changed (to emit event) if includeNewPages is true
204+
if (this.includeNewPages) {
205+
propertyHasChanged = true;
206+
changes.push({
207+
property: propertyName,
208+
previousValue,
209+
currentValue: currentValueToEmit,
210+
});
211+
}
212+
}
210213
}
211214

212-
if (propertyHasChanged) {
215+
// Only emit events if:
216+
// 1. It's an existing page with changes, OR
217+
// 2. It's a new page and includeNewPages is true
218+
if (propertyHasChanged && (!isNewPage || this.includeNewPages)) {
213219
this._emitEvent(page, changes, isNewPage);
214220
}
215221
}

pnpm-lock.yaml

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)