Merge pull request #2929 from omnivore-app/fix/highlighted-markdown
fetch highlights if necessary and before converting content to markdown
This commit is contained in:
@ -53,6 +53,7 @@ import { getInternalLabelWithColor } from '../../repository/label'
|
||||
import { libraryItemRepository } from '../../repository/library_item'
|
||||
import { userRepository } from '../../repository/user'
|
||||
import { createPageSaveRequest } from '../../services/create_page_save_request'
|
||||
import { findHighlightsByLibraryItemId } from '../../services/highlights'
|
||||
import {
|
||||
addLabelsToLibraryItem,
|
||||
findLabelsByIds,
|
||||
@ -631,7 +632,7 @@ export const searchResolver = authorized<
|
||||
SearchSuccess,
|
||||
SearchError,
|
||||
QuerySearchArgs
|
||||
>(async (_obj, params, { uid, log }) => {
|
||||
>(async (_obj, params, { log, uid }) => {
|
||||
const startCursor = params.after || ''
|
||||
const first = params.first || 10
|
||||
|
||||
@ -664,6 +665,21 @@ export const searchResolver = authorized<
|
||||
libraryItems.pop()
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
libraryItems.map(async (libraryItem) => {
|
||||
if (
|
||||
libraryItem.highlightAnnotations &&
|
||||
libraryItem.highlightAnnotations.length > 0
|
||||
) {
|
||||
// fetch highlights for each item
|
||||
libraryItem.highlights = await findHighlightsByLibraryItemId(
|
||||
libraryItem.id,
|
||||
uid
|
||||
)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
const edges = libraryItems.map((libraryItem) => {
|
||||
if (libraryItem.siteIcon && !isBase64Image(libraryItem.siteIcon)) {
|
||||
libraryItem.siteIcon = createImageProxyUrl(libraryItem.siteIcon, 128, 128)
|
||||
|
||||
@ -6,18 +6,15 @@
|
||||
import { Subscription } from '../entity/subscription'
|
||||
import {
|
||||
Article,
|
||||
Highlight,
|
||||
Label,
|
||||
PageType,
|
||||
Recommendation,
|
||||
SearchItem,
|
||||
} from '../generated/graphql'
|
||||
import { findHighlightsByLibraryItemId } from '../services/highlights'
|
||||
import { findLabelsByLibraryItemId } from '../services/labels'
|
||||
import { findRecommendationsByLibraryItemId } from '../services/recommendation'
|
||||
import { findUploadFileById } from '../services/upload_file'
|
||||
import {
|
||||
highlightDataToHighlight,
|
||||
recommandationDataToRecommendation,
|
||||
validatedDate,
|
||||
wordsCount,
|
||||
@ -486,16 +483,6 @@ export const functionResolvers = {
|
||||
if (item.wordCount) return item.wordCount
|
||||
return item.content ? wordsCount(item.content) : undefined
|
||||
},
|
||||
async highlights(
|
||||
item: { id: string; highlights?: Highlight[] },
|
||||
_: unknown,
|
||||
ctx: WithDataSourcesContext
|
||||
) {
|
||||
if (item.highlights) return item.highlights
|
||||
|
||||
const highlights = await findHighlightsByLibraryItemId(item.id, ctx.uid)
|
||||
return highlights.map(highlightDataToHighlight)
|
||||
},
|
||||
async labels(
|
||||
item: { id: string; labels?: Label[] },
|
||||
_: unknown,
|
||||
|
||||
Reference in New Issue
Block a user