From 73c86a866f6f41a9e1b5c26850212a8aca4c4239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20H=C3=B6ffler?= Date: Fri, 19 Jul 2024 14:29:25 +0200 Subject: [PATCH] Added guard against emitting empty snapshot values --- templates/lib/utils/helpers.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/lib/utils/helpers.js b/templates/lib/utils/helpers.js index 7516018..a8eea63 100644 --- a/templates/lib/utils/helpers.js +++ b/templates/lib/utils/helpers.js @@ -209,9 +209,12 @@ async function dataAndSnapshot(newElement, snapshot, snapshotKey, standardSnapsh } } this.logger.info("%s items were emitted", emittedItemsCount); - snapshot.lastUpdated = lastObjectDate !== 0 ? lastObjectDate : snapshot.lastUpdated; - await self.emit("snapshot", snapshot); - this.logger.info("A new snapshot was emitted: %j", snapshot); + this.logger.info("Generating snapshot, found latest object date %s", lastObjectDate); + snapshot.lastUpdated = lastObjectDate ? lastObjectDate : snapshot.lastUpdated; + if (snapshot.lastUpdated) { + await self.emit("snapshot", snapshot); + this.logger.info("A new snapshot was emitted: %j", snapshot); + } } else { this.logger.info("Found one item in response data, going to emit..."); await self.emit("data", newElement);