chore: fix ContentType usage (#2353)

* chore: fix ContentType usage

* chore: fix specs
This commit is contained in:
Karol Sójko
2023-07-12 13:53:29 +02:00
committed by GitHub
parent d057cdff84
commit 325737bfbd
247 changed files with 1092 additions and 1060 deletions

View File

@@ -9,8 +9,10 @@ import { formatCount } from './formatCount'
const EncryptionEnabled: FunctionComponent = () => {
const application = useApplication()
const itemCounter = new StaticItemCounter()
const count = itemCounter.countNotesAndTags(application.items.getItems([ContentType.Note, ContentType.Tag]))
const files = application.items.getItems([ContentType.File])
const count = itemCounter.countNotesAndTags(
application.items.getItems([ContentType.TYPES.Note, ContentType.TYPES.Tag]),
)
const files = application.items.getItems([ContentType.TYPES.File])
const notes = formatCount(count.notes, 'notes')
const tags = formatCount(count.tags, 'tags')
const archived = formatCount(count.archived, 'archived notes')

View File

@@ -1,13 +1,7 @@
import { observer } from 'mobx-react-lite'
import { Fragment, FunctionComponent, useEffect, useState } from 'react'
import { Text, Title, Subtitle } from '@/Components/Preferences/PreferencesComponents/Content'
import {
ButtonType,
ClientDisplayableError,
ContentType,
DisplayStringForContentType,
EncryptedItemInterface,
} from '@standardnotes/snjs'
import { ButtonType, ClientDisplayableError, ContentType, EncryptedItemInterface } from '@standardnotes/snjs'
import Button from '@/Components/Button/Button'
import HorizontalSeparator from '@/Components/Shared/HorizontalSeparator'
import PreferencesSegment from '../../PreferencesComponents/PreferencesSegment'
@@ -20,13 +14,17 @@ const ErroredItems: FunctionComponent = () => {
const [erroredItems, setErroredItems] = useState(application.items.invalidNonVaultedItems)
useEffect(() => {
return application.streamItems(ContentType.Any, () => {
return application.streamItems(ContentType.TYPES.Any, () => {
setErroredItems(application.items.invalidNonVaultedItems)
})
}, [application])
const getContentTypeDisplay = (item: EncryptedItemInterface): string => {
const display = DisplayStringForContentType(item.content_type)
const contentTypeOrError = ContentType.create(item.content_type)
let display = null
if (!contentTypeOrError.isFailed()) {
display = contentTypeOrError.getValue().getDisplayName()
}
if (display) {
return `${display[0].toUpperCase()}${display.slice(1)}`
} else {