@activepieces/pieces-common
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "@activepieces/pieces-common", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"type": "commonjs", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -5,2 +5,3 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const lodash_1 = require("lodash"); | ||
var DedupeStrategy; | ||
@@ -13,3 +14,3 @@ (function (DedupeStrategy) { | ||
poll(polling, { store, propsValue }) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
@@ -28,9 +29,10 @@ switch (polling.strategy) { | ||
const newLastItem = (_b = items === null || items === void 0 ? void 0 : items[0]) === null || _b === void 0 ? void 0 : _b.id; | ||
if (!lastItemId || !newLastItem) { | ||
return items; | ||
if (!(0, lodash_1.isNil)(newLastItem)) { | ||
yield store.put("lastItem", newLastItem); | ||
} | ||
yield store.put("lastItem", newLastItem); | ||
// get items until you find the last item | ||
const lastItemIndex = items.findIndex(f => f.id === lastItemId); | ||
return (_c = items === null || items === void 0 ? void 0 : items.slice(0, lastItemIndex).map((item) => item.data)) !== null && _c !== void 0 ? _c : []; | ||
if ((0, lodash_1.isNil)(lastItemId) || lastItemIndex == -1) { | ||
return (_c = items === null || items === void 0 ? void 0 : items.map((item) => item.data)) !== null && _c !== void 0 ? _c : []; | ||
} | ||
return (_d = items === null || items === void 0 ? void 0 : items.slice(0, lastItemIndex).map((item) => item.data)) !== null && _d !== void 0 ? _d : []; | ||
} | ||
@@ -50,3 +52,9 @@ } | ||
const items = (yield polling.items({ propsValue, lastItemId: null })); | ||
yield store.put("lastItem", (_a = items === null || items === void 0 ? void 0 : items[0]) === null || _a === void 0 ? void 0 : _a.id); | ||
const lastItemId = (_a = items === null || items === void 0 ? void 0 : items[0]) === null || _a === void 0 ? void 0 : _a.id; | ||
if (!(0, lodash_1.isNil)(lastItemId)) { | ||
yield store.put("lastItem", lastItemId); | ||
} | ||
else { | ||
yield store.delete("lastItem"); | ||
} | ||
break; | ||
@@ -53,0 +61,0 @@ } |
Sorry, the diff of this file is not supported yet
37224
558