chore: fix ContentType usage (#2353)
* chore: fix ContentType usage * chore: fix specs
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { SmartView } from '../../Syncable/SmartView'
|
||||
import { SNTag } from '../../Syncable/Tag'
|
||||
import { CollectionSortDirection, CollectionSortProperty } from '../Collection/CollectionSort'
|
||||
@@ -16,7 +15,7 @@ export interface NotesAndFilesDisplayOptions extends GenericDisplayOptions {
|
||||
tags?: SNTag[]
|
||||
views?: SmartView[]
|
||||
searchQuery?: SearchQuery
|
||||
hiddenContentTypes?: ContentType[]
|
||||
hiddenContentTypes?: string[]
|
||||
customFilter?: DisplayControllerCustomFilter
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { DecryptedItem } from '../../Abstract/Item'
|
||||
import { SNTag } from '../../Syncable/Tag'
|
||||
import { CompoundPredicate } from '../Predicate/CompoundPredicate'
|
||||
@@ -7,6 +6,7 @@ import { itemMatchesQuery, itemPassesFilters } from './Search/SearchUtilities'
|
||||
import { ItemFilter, ReferenceLookupCollection, SearchableDecryptedItem } from './Search/Types'
|
||||
import { NotesAndFilesDisplayOptions } from './DisplayOptions'
|
||||
import { SystemViewId } from '../../Syncable/SmartView'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
|
||||
export function computeUnifiedFilterForDisplayOptions(
|
||||
options: NotesAndFilesDisplayOptions,
|
||||
@@ -40,7 +40,7 @@ export function computeFiltersForDisplayOptions(
|
||||
const noteWithTags = ItemWithTags.Create(
|
||||
item.payload,
|
||||
item,
|
||||
collection.elementsReferencingElement(item, ContentType.Tag) as SNTag[],
|
||||
collection.elementsReferencingElement(item, ContentType.TYPES.Tag) as SNTag[],
|
||||
)
|
||||
return compoundPredicate.matchesItem(noteWithTags)
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CreateItemDelta } from './../Index/ItemDelta'
|
||||
import { DeletedPayload } from './../../Abstract/Payload/Implementations/DeletedPayload'
|
||||
import { createFile, createNote, createTagWithTitle, mockUuid, pinnedContent } from './../../Utilities/Test/SpecUtils'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { DeletedItem, EncryptedItem } from '../../Abstract/Item'
|
||||
import { EncryptedPayload, PayloadTimestampDefaults } from '../../Abstract/Payload'
|
||||
import { createNoteWithContent } from '../../Utilities/Test/SpecUtils'
|
||||
@@ -16,7 +16,7 @@ describe('item display controller', () => {
|
||||
const noteB = createNoteWithContent({ title: 'b' })
|
||||
collection.set([noteA, noteB])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -36,7 +36,7 @@ describe('item display controller', () => {
|
||||
const noteB = createNoteWithContent({ title: 'b' })
|
||||
collection.set([noteA, noteB])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -56,7 +56,7 @@ describe('item display controller', () => {
|
||||
const noteA = createNoteWithContent({ title: 'a' })
|
||||
collection.set([noteA])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -76,7 +76,7 @@ describe('item display controller', () => {
|
||||
const noteA = new EncryptedItem(
|
||||
new EncryptedPayload({
|
||||
uuid: mockUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: '004:...',
|
||||
enc_item_key: '004:...',
|
||||
items_key_id: mockUuid(),
|
||||
@@ -87,7 +87,7 @@ describe('item display controller', () => {
|
||||
)
|
||||
collection.set([noteA])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -101,7 +101,7 @@ describe('item display controller', () => {
|
||||
const noteB = createNoteWithContent({ title: 'b' })
|
||||
collection.set([noteA, noteB])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -134,7 +134,7 @@ describe('item display controller', () => {
|
||||
const noteA = createNoteWithContent({ title: 'a' })
|
||||
collection.set([noteA])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -159,7 +159,7 @@ describe('item display controller', () => {
|
||||
const noteA = createNoteWithContent({ title: 'a' })
|
||||
collection.set([noteA])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -177,7 +177,7 @@ describe('item display controller', () => {
|
||||
const tag = createTagWithTitle()
|
||||
collection.set([note, tag])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -190,7 +190,7 @@ describe('item display controller', () => {
|
||||
const tag = createTagWithTitle()
|
||||
collection.set([note, tag])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -203,7 +203,7 @@ describe('item display controller', () => {
|
||||
const note = createNoteWithContent({ title: 'a' })
|
||||
collection.set([note])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -222,7 +222,7 @@ describe('item display controller', () => {
|
||||
const file = createFile('A')
|
||||
collection.set([note, file])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note, ContentType.File], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note, ContentType.TYPES.File], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
@@ -242,14 +242,14 @@ describe('item display controller', () => {
|
||||
const file = createFile()
|
||||
collection.set([note, file])
|
||||
|
||||
const controller = new ItemDisplayController(collection, [ContentType.Note, ContentType.File], {
|
||||
const controller = new ItemDisplayController(collection, [ContentType.TYPES.Note, ContentType.TYPES.File], {
|
||||
sortBy: 'title',
|
||||
sortDirection: 'asc',
|
||||
})
|
||||
|
||||
expect(controller.items()).toHaveLength(2)
|
||||
|
||||
controller.setDisplayOptions({ hiddenContentTypes: [ContentType.File] })
|
||||
controller.setDisplayOptions({ hiddenContentTypes: [ContentType.TYPES.File] })
|
||||
|
||||
expect(controller.items()).toHaveLength(1)
|
||||
})
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { compareValues } from '@standardnotes/utils'
|
||||
import { isDeletedItem, isEncryptedItem } from '../../Abstract/Item'
|
||||
import { ItemDelta } from '../Index/ItemDelta'
|
||||
@@ -21,7 +20,7 @@ export class ItemDisplayController<I extends DisplayItem, O extends AnyDisplayOp
|
||||
|
||||
constructor(
|
||||
private readonly collection: ReadonlyItemCollection,
|
||||
public readonly contentTypes: ContentType[],
|
||||
public readonly contentTypes: string[],
|
||||
private options: DisplayControllerDisplayOptions & O,
|
||||
private vaultOptions?: VaultDisplayOptions,
|
||||
) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { SNTag } from '../../../Syncable/Tag'
|
||||
import { NotesAndFilesDisplayOptions } from '../DisplayOptions'
|
||||
import { computeFiltersForDisplayOptions } from '../DisplayOptionsToFilters'
|
||||
@@ -38,7 +38,7 @@ export function itemMatchesQuery(
|
||||
searchQuery: SearchQuery,
|
||||
collection: ReferenceLookupCollection,
|
||||
): boolean {
|
||||
const itemTags = collection.elementsReferencingElement(itemToMatch, ContentType.Tag) as SNTag[]
|
||||
const itemTags = collection.elementsReferencingElement(itemToMatch, ContentType.TYPES.Tag) as SNTag[]
|
||||
const someTagsMatches = itemTags.some((tag) => matchResultForStringQuery(tag, searchQuery.query) !== MatchResult.None)
|
||||
|
||||
if (itemToMatch.protected && !searchQuery.includeProtectedNoteText) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { DecryptedItemInterface } from './../../../Abstract/Item/Interfaces/DecryptedItem'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { CriteriaValidatorInterface } from './CriteriaValidatorInterface'
|
||||
|
||||
export class HiddenContentCriteriaValidator implements CriteriaValidatorInterface {
|
||||
constructor(private hiddenContentTypes: ContentType[], private element: DecryptedItemInterface) {}
|
||||
constructor(private hiddenContentTypes: string[], private element: DecryptedItemInterface) {}
|
||||
|
||||
public passes(): boolean {
|
||||
return !this.hiddenContentTypes.includes(this.element.content_type)
|
||||
|
||||
Reference in New Issue
Block a user