Skip to content

Commit 8e93c57

Browse files
authored
Merge pull request #73 from omnivore-app/fix/labels-in-highlights
fix: labels in highlights are not retrieved
2 parents d899928 + fa26e85 commit 8e93c57

File tree

2 files changed

+61
-10
lines changed

2 files changed

+61
-10
lines changed

src/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import {
88
import {
99
Article,
1010
compareHighlightsInFile,
11+
DATE_FORMAT,
1112
escapeQuotationMarks,
13+
formatDate,
1214
getHighlightLocation,
1315
loadArticles,
1416
loadDeletedArticleSlugs,
1517
PageType,
1618
parseDateTime,
17-
DATE_FORMAT,
18-
formatDate,
1919
} from './util'
2020
import { DateTime } from 'luxon'
2121
import { render } from 'mustache'
@@ -92,10 +92,12 @@ const fetchOmnivore = async (inBackground = false) => {
9292
} = logseq.settings as Settings
9393

9494
if (!apiKey) {
95-
await logseq.UI.showMsg('Missing Omnivore api key', 'warning', { timeout: 3000 }).then(() => {
95+
await logseq.UI.showMsg('Missing Omnivore api key', 'warning', {
96+
timeout: 3000,
97+
}).then(() => {
9698
logseq.showSettingsUI()
97-
setTimeout(function () {
98-
logseq.App.openExternalLink('https://omnivore.app/settings/api')
99+
setTimeout(async function () {
100+
await logseq.App.openExternalLink('https://omnivore.app/settings/api')
99101
}, 3000)
100102
})
101103
return
@@ -161,7 +163,7 @@ const fetchOmnivore = async (inBackground = false) => {
161163
size,
162164
parseDateTime(syncAt).toISO(),
163165
getQueryFromFilter(filter, customQuery),
164-
'true',
166+
true,
165167
'markdown'
166168
)
167169

src/util.ts

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,63 @@ export const loadArticles = async (
112112
first = 10,
113113
updatedAt = '',
114114
query = '',
115-
includeContent: 'true' | 'false' = 'false',
115+
includeContent = false,
116116
format = 'html'
117117
): Promise<[Article[], boolean]> => {
118118
const res = await fetch(ENDPOINT, {
119119
headers: requestHeaders(apiKey),
120-
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":"${
121-
updatedAt ? 'updated:' + updatedAt : ''
122-
} sort:saved-asc ${query}", "includeContent": ${includeContent}, "format": "${format}"}}`,
120+
body: JSON.stringify({
121+
query: `
122+
query Search($after: String, $first: Int, $query: String, $includeContent: Boolean, $format: String) {
123+
search(first: $first, after: $after, query: $query, includeContent: $includeContent, format: $format) {
124+
... on SearchSuccess {
125+
edges {
126+
node {
127+
title
128+
slug
129+
siteName
130+
originalArticleUrl
131+
url
132+
author
133+
updatedAt
134+
description
135+
savedAt
136+
pageType
137+
content
138+
highlights {
139+
id
140+
quote
141+
annotation
142+
patch
143+
updatedAt
144+
labels {
145+
name
146+
}
147+
}
148+
labels {
149+
name
150+
}
151+
}
152+
}
153+
pageInfo {
154+
hasNextPage
155+
}
156+
}
157+
... on SearchError {
158+
errorCodes
159+
}
160+
}
161+
}`,
162+
variables: {
163+
after: `${after}`,
164+
first,
165+
query: `${
166+
updatedAt ? 'updated:' + updatedAt : ''
167+
} sort:saved-asc ${query}`,
168+
includeContent,
169+
format,
170+
},
171+
}),
123172
method: 'POST',
124173
})
125174

0 commit comments

Comments
 (0)