Skip to content

Commit

Permalink
Merge pull request #73 from omnivore-app/fix/labels-in-highlights
Browse files Browse the repository at this point in the history
fix: labels in highlights are not retrieved
  • Loading branch information
sywhb authored Feb 21, 2023
2 parents d899928 + fa26e85 commit 8e93c57
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 10 deletions.
14 changes: 8 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
import {
Article,
compareHighlightsInFile,
DATE_FORMAT,
escapeQuotationMarks,
formatDate,
getHighlightLocation,
loadArticles,
loadDeletedArticleSlugs,
PageType,
parseDateTime,
DATE_FORMAT,
formatDate,
} from './util'
import { DateTime } from 'luxon'
import { render } from 'mustache'
Expand Down Expand Up @@ -92,10 +92,12 @@ const fetchOmnivore = async (inBackground = false) => {
} = logseq.settings as Settings

if (!apiKey) {
await logseq.UI.showMsg('Missing Omnivore api key', 'warning', { timeout: 3000 }).then(() => {
await logseq.UI.showMsg('Missing Omnivore api key', 'warning', {
timeout: 3000,
}).then(() => {
logseq.showSettingsUI()
setTimeout(function () {
logseq.App.openExternalLink('https://omnivore.app/settings/api')
setTimeout(async function () {
await logseq.App.openExternalLink('https://omnivore.app/settings/api')
}, 3000)
})
return
Expand Down Expand Up @@ -161,7 +163,7 @@ const fetchOmnivore = async (inBackground = false) => {
size,
parseDateTime(syncAt).toISO(),
getQueryFromFilter(filter, customQuery),
'true',
true,
'markdown'
)

Expand Down
57 changes: 53 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,63 @@ export const loadArticles = async (
first = 10,
updatedAt = '',
query = '',
includeContent: 'true' | 'false' = 'false',
includeContent = false,
format = 'html'
): Promise<[Article[], boolean]> => {
const res = await fetch(ENDPOINT, {
headers: requestHeaders(apiKey),
body: `{"query":"\\n query Search($after: String, $first: Int, $query: String, $includeContent: Boolean, $format: String) {\\n search(first: $first, after: $after, query: $query, includeContent: $includeContent, format: $format) {\\n ... on SearchSuccess {\\n edges {\\n node {\\n title\\n slug\\n siteName\\n originalArticleUrl\\n url\\n author\\n updatedAt\\n description\\n savedAt\\n pageType\\n content\\n highlights {\\n id\\n quote\\n annotation\\n patch\\n updatedAt\\n }\\n labels {\\n name\\n }\\n }\\n }\\n pageInfo {\\n hasNextPage\\n }\\n }\\n ... on SearchError {\\n errorCodes\\n }\\n }\\n }\\n ","variables":{"after":"${after}","first":${first}, "query":"${
updatedAt ? 'updated:' + updatedAt : ''
} sort:saved-asc ${query}", "includeContent": ${includeContent}, "format": "${format}"}}`,
body: JSON.stringify({
query: `
query Search($after: String, $first: Int, $query: String, $includeContent: Boolean, $format: String) {
search(first: $first, after: $after, query: $query, includeContent: $includeContent, format: $format) {
... on SearchSuccess {
edges {
node {
title
slug
siteName
originalArticleUrl
url
author
updatedAt
description
savedAt
pageType
content
highlights {
id
quote
annotation
patch
updatedAt
labels {
name
}
}
labels {
name
}
}
}
pageInfo {
hasNextPage
}
}
... on SearchError {
errorCodes
}
}
}`,
variables: {
after: `${after}`,
first,
query: `${
updatedAt ? 'updated:' + updatedAt : ''
} sort:saved-asc ${query}`,
includeContent,
format,
},
}),
method: 'POST',
})

Expand Down

0 comments on commit 8e93c57

Please sign in to comment.