mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
add in:following search filter
This commit is contained in:
parent
a00ce8893e
commit
3ff9ce3a09
5 changed files with 41 additions and 46 deletions
|
|
@ -95,7 +95,11 @@ import {
|
|||
ParsedContentPuppeteer,
|
||||
parsePreparedContent,
|
||||
} from '../../utils/parser'
|
||||
import { parseSearchQuery, sortParamsToSort } from '../../utils/search'
|
||||
import {
|
||||
InFilter,
|
||||
parseSearchQuery,
|
||||
sortParamsToSort,
|
||||
} from '../../utils/search'
|
||||
import { getStorageFileDetails } from '../../utils/uploads'
|
||||
import { itemTypeForContentType } from '../upload_files'
|
||||
|
||||
|
|
@ -736,7 +740,7 @@ export const updatesSinceResolver = authorized<
|
|||
const sort = sortParamsToSort(sortParams)
|
||||
|
||||
const startCursor = after || ''
|
||||
const size = first || 10
|
||||
const size = Math.min(first || 10, 100) // limit to 100 items
|
||||
let startDate = new Date(since)
|
||||
if (isNaN(startDate.getTime())) {
|
||||
// for android app compatibility
|
||||
|
|
|
|||
|
|
@ -103,40 +103,41 @@ const buildWhereClause = (
|
|||
})
|
||||
}
|
||||
|
||||
if (args.inFilter !== InFilter.FOLLOWING) {
|
||||
queryBuilder.andWhere('library_item.is_in_library = true')
|
||||
if (args.inFilter !== InFilter.ALL) {
|
||||
if (args.inFilter === InFilter.FOLLOWING) {
|
||||
queryBuilder
|
||||
.andWhere('library_item.shared_by IS NOT NULL')
|
||||
.andWhere('library_item.hidden_at IS NULL')
|
||||
} else {
|
||||
queryBuilder.andWhere('library_item.is_in_library = true')
|
||||
|
||||
switch (args.inFilter) {
|
||||
case InFilter.INBOX:
|
||||
queryBuilder.andWhere('library_item.archived_at IS NULL')
|
||||
break
|
||||
case InFilter.ARCHIVE:
|
||||
queryBuilder.andWhere('library_item.archived_at IS NOT NULL')
|
||||
break
|
||||
case InFilter.TRASH:
|
||||
// return only deleted pages within 14 days
|
||||
queryBuilder.andWhere(
|
||||
"library_item.deleted_at >= now() - interval '14 days'"
|
||||
)
|
||||
break
|
||||
case InFilter.SUBSCRIPTION:
|
||||
queryBuilder
|
||||
.andWhere("NOT ('library' ILIKE ANY (library_item.label_names))")
|
||||
.andWhere('library_item.archived_at IS NULL')
|
||||
.andWhere('library_item.subscription IS NOT NULL')
|
||||
break
|
||||
case InFilter.LIBRARY:
|
||||
queryBuilder
|
||||
.andWhere(
|
||||
"(library_item.subscription IS NULL OR 'library' ILIKE ANY (library_item.label_names))"
|
||||
switch (args.inFilter) {
|
||||
case InFilter.INBOX:
|
||||
queryBuilder.andWhere('library_item.archived_at IS NULL')
|
||||
break
|
||||
case InFilter.ARCHIVE:
|
||||
queryBuilder.andWhere('library_item.archived_at IS NOT NULL')
|
||||
break
|
||||
case InFilter.TRASH:
|
||||
// return only deleted pages within 14 days
|
||||
queryBuilder.andWhere(
|
||||
"library_item.deleted_at >= now() - interval '14 days'"
|
||||
)
|
||||
.andWhere('library_item.archived_at IS NULL')
|
||||
break
|
||||
break
|
||||
case InFilter.SUBSCRIPTION:
|
||||
queryBuilder
|
||||
.andWhere("NOT ('library' ILIKE ANY (library_item.label_names))")
|
||||
.andWhere('library_item.archived_at IS NULL')
|
||||
.andWhere('library_item.subscription IS NOT NULL')
|
||||
break
|
||||
case InFilter.LIBRARY:
|
||||
queryBuilder
|
||||
.andWhere(
|
||||
"(library_item.subscription IS NULL OR 'library' ILIKE ANY (library_item.label_names))"
|
||||
)
|
||||
.andWhere('library_item.archived_at IS NULL')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
queryBuilder
|
||||
.andWhere('library_item.shared_by IS NOT NULL')
|
||||
.andWhere('library_item.hidden_at IS NULL')
|
||||
}
|
||||
|
||||
if (args.readFilter !== ReadFilter.ALL) {
|
||||
|
|
|
|||
|
|
@ -138,6 +138,8 @@ const parseInFilter = (
|
|||
return InFilter.SUBSCRIPTION
|
||||
case 'LIBRARY':
|
||||
return InFilter.LIBRARY
|
||||
case 'FOLLOWING':
|
||||
return InFilter.FOLLOWING
|
||||
}
|
||||
|
||||
return query ? InFilter.ALL : InFilter.INBOX
|
||||
|
|
@ -409,19 +411,7 @@ export const parseSearchQuery = (query: string | undefined): SearchFilter => {
|
|||
}
|
||||
|
||||
if (!searchQuery) {
|
||||
return {
|
||||
query: undefined,
|
||||
inFilter: InFilter.INBOX,
|
||||
readFilter: ReadFilter.ALL,
|
||||
labelFilters: [],
|
||||
hasFilters: [],
|
||||
dateFilters: [],
|
||||
termFilters: [],
|
||||
matchFilters: [],
|
||||
ids: [],
|
||||
noFilters: [],
|
||||
rangeFilters: [],
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
const parsed = parse(searchQuery, {
|
||||
|
|
|
|||
Loading…
Reference in a new issue