From 1c31e5fc153ddd00a79d4866610778845ae03274 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 28 Oct 2022 15:05:16 +0800 Subject: [PATCH] Skip sync with Readwise if no highlights --- packages/api/src/services/integrations.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/api/src/services/integrations.ts b/packages/api/src/services/integrations.ts index f13b68d3e..00f65a4ed 100644 --- a/packages/api/src/services/integrations.ts +++ b/packages/api/src/services/integrations.ts @@ -88,14 +88,16 @@ export const syncWithIntegration = async ( integration: Integration, pages: Page[] ): Promise => { - let result = false + let result = true switch (integration.type) { - case IntegrationType.Readwise: - result = await syncWithReadwise( - integration.token, - pages.flatMap(pageToReadwiseHighlight) - ) + case IntegrationType.Readwise: { + const highlights = pages.flatMap(pageToReadwiseHighlight) + // If there are no highlights, we will skip the sync + if (highlights.length > 0) { + result = await syncWithReadwise(integration.token, highlights) + } break + } default: return false }