Skip to content

Commit c568c84

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix-add-to-calender-pro-updates
2 parents 5880a44 + 53f0b06 commit c568c84

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

components/intercom/package.json

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

components/intercom/sources/new-conversation-rating-added/new-conversation-rating-added.mjs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@ export default {
55
key: "intercom-new-conversation-rating-added",
66
name: "New Conversation Rating Added",
77
description: "Emit new event each time a new rating is added to a conversation.",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "source",
1010
dedupe: "unique",
11+
props: {
12+
...common.props,
13+
newConversationsOnly: {
14+
type: "boolean",
15+
label: "New Conversations Only",
16+
description: "Set to `true` to only emit events for new conversations",
17+
optional: true,
18+
},
19+
},
1120
methods: {
1221
...common.methods,
1322
generateMeta(conversation) {
@@ -20,7 +29,8 @@ export default {
2029
},
2130
},
2231
async run() {
23-
let lastRatingCreatedAt = this._getLastUpdate();
32+
const lastRatingCreatedAt = this._getLastUpdate();
33+
let maxLastRatingCreatedAt = lastRatingCreatedAt;
2434
const data = {
2535
query: {
2636
field: "conversation_rating.requested_at",
@@ -32,12 +42,14 @@ export default {
3242
const results = await this.intercom.searchConversations(data);
3343
for (const conversation of results) {
3444
const createdAt = conversation.conversation_rating.created_at;
35-
if (createdAt > lastRatingCreatedAt)
36-
lastRatingCreatedAt = createdAt;
37-
const meta = this.generateMeta(conversation);
38-
this.$emit(conversation, meta);
45+
if (createdAt > maxLastRatingCreatedAt)
46+
maxLastRatingCreatedAt = createdAt;
47+
if (!this.newConversationsOnly || conversation.created_at > lastRatingCreatedAt) {
48+
const meta = this.generateMeta(conversation);
49+
this.$emit(conversation, meta);
50+
}
3951
}
4052

41-
this._setLastUpdate(lastRatingCreatedAt);
53+
this._setLastUpdate(maxLastRatingCreatedAt);
4254
},
4355
};

0 commit comments

Comments
 (0)