Merge pull request #1361 from omnivore-app/fix/sync-readwise

Skip sync with Readwise if no highlights
This commit is contained in:
Hongbo Wu
2022-10-28 15:07:27 +08:00
committed by GitHub

View File

@ -88,14 +88,16 @@ export const syncWithIntegration = async (
integration: Integration,
pages: Page[]
): Promise<boolean> => {
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
}