chore: fix compound predicates which involve tags

This commit is contained in:
Mo
2023-05-08 07:16:02 -05:00
parent b811d619e3
commit f9fccf7140

View File

@@ -1,3 +1,4 @@
import { omitByCopy } from '@standardnotes/utils'
import { SearchableDecryptedItem } from './Types'
import { ItemContent } from '../../../Abstract/Content/ItemContent'
import { DecryptedItem } from '../../../Abstract/Item'
@@ -15,9 +16,14 @@ export class ItemWithTags extends DecryptedItem implements SearchableDecryptedIt
public readonly tags?: SNTag[],
) {
super(payload)
this.transferInItemPropertiesSoRootLevelPredicateKeyPathsCanBeMatched(item)
this.tags = tags || payload.content.tags
}
transferInItemPropertiesSoRootLevelPredicateKeyPathsCanBeMatched(item: SearchableDecryptedItem) {
Object.assign(this, omitByCopy(item, ['title', 'text']))
}
static Create(payload: DecryptedPayloadInterface<ItemContent>, item: SearchableDecryptedItem, tags?: SNTag[]) {
return new ItemWithTags(payload as DecryptedPayloadInterface<ItemWithTagsContent>, item, tags)
}