mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
show archived highlights
This commit is contained in:
parent
2e26a04cd0
commit
40182421f7
3 changed files with 14 additions and 25 deletions
|
|
@ -6,7 +6,7 @@
|
|||
import { createHmac } from 'crypto'
|
||||
import { isError } from 'lodash'
|
||||
import { Highlight } from '../entity/highlight'
|
||||
import { LibraryItem } from '../entity/library_item'
|
||||
import { LibraryItem, LibraryItemState } from '../entity/library_item'
|
||||
import {
|
||||
EXISTING_NEWSLETTER_FOLDER,
|
||||
NewsletterEmail,
|
||||
|
|
@ -634,7 +634,14 @@ export const functionResolvers = {
|
|||
const libraryItems = (
|
||||
await ctx.dataLoaders.libraryItems.loadMany(libraryItemIds)
|
||||
).filter(
|
||||
(libraryItem) => !!libraryItem && !isError(libraryItem)
|
||||
(libraryItem) =>
|
||||
!!libraryItem &&
|
||||
!isError(libraryItem) &&
|
||||
[
|
||||
LibraryItemState.Succeeded,
|
||||
LibraryItemState.ContentNotFetched,
|
||||
].includes(libraryItem.state) &&
|
||||
!libraryItem.seenAt
|
||||
) as Array<LibraryItem>
|
||||
|
||||
const publicItemIds = section.items
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ export const batchGetHighlightsFromLibraryItemIds = async (
|
|||
const highlights = await authTrx(async (tx) =>
|
||||
tx.getRepository(Highlight).find({
|
||||
where: { libraryItem: { id: In(libraryItemIds as string[]) } },
|
||||
relations: ['user'],
|
||||
})
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import {
|
|||
EntityManager,
|
||||
FindOptionsWhere,
|
||||
In,
|
||||
IsNull,
|
||||
ObjectLiteral,
|
||||
} from 'typeorm'
|
||||
import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity'
|
||||
|
|
@ -135,31 +134,15 @@ export enum SortBy {
|
|||
const readingProgressDataSource = new ReadingProgressDataSource()
|
||||
|
||||
export const batchGetLibraryItems = async (ids: readonly string[]) => {
|
||||
const selectColumns: Array<keyof LibraryItem> = [
|
||||
'id',
|
||||
'title',
|
||||
'author',
|
||||
'thumbnail',
|
||||
'wordCount',
|
||||
'savedAt',
|
||||
'originalUrl',
|
||||
'directionality',
|
||||
'description',
|
||||
'subscription',
|
||||
'siteName',
|
||||
'siteIcon',
|
||||
'archivedAt',
|
||||
'deletedAt',
|
||||
'slug',
|
||||
'previewContent',
|
||||
]
|
||||
// select all columns except content
|
||||
const select = getColumns(libraryItemRepository).filter(
|
||||
(select) => ['originalContent', 'readableContent'].indexOf(select) === -1
|
||||
)
|
||||
const items = await authTrx(async (tx) =>
|
||||
tx.getRepository(LibraryItem).find({
|
||||
select: selectColumns,
|
||||
select,
|
||||
where: {
|
||||
id: In(ids as string[]),
|
||||
state: LibraryItemState.Succeeded,
|
||||
seenAt: IsNull(),
|
||||
},
|
||||
})
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue