chore: fix ContentType usage (#2353)
* chore: fix ContentType usage * chore: fix specs
This commit is contained in:
@@ -55,7 +55,7 @@ const Appearance: FunctionComponent<Props> = ({ application }) => {
|
||||
})
|
||||
|
||||
GetFeatures()
|
||||
.filter((feature) => feature.content_type === ContentType.Theme && !feature.layerable)
|
||||
.filter((feature) => feature.content_type === ContentType.TYPES.Theme && !feature.layerable)
|
||||
.forEach((theme) => {
|
||||
themesAsItems.push({
|
||||
label: theme.name as string,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { DisplayStringForContentType } from '@standardnotes/snjs'
|
||||
import { ContentType } from '@standardnotes/snjs'
|
||||
|
||||
import Button from '@/Components/Button/Button'
|
||||
import { Fragment, FunctionComponent } from 'react'
|
||||
import { Title, Text, Subtitle } from '@/Components/Preferences/PreferencesComponents/Content'
|
||||
@@ -9,6 +10,12 @@ const ConfirmCustomPackage: FunctionComponent<{
|
||||
component: AnyPackageType
|
||||
callback: (confirmed: boolean) => void
|
||||
}> = ({ component, callback }) => {
|
||||
let contentTypeDisplayName = null
|
||||
const contentTypeOrError = ContentType.create(component.content_type)
|
||||
if (!contentTypeOrError.isFailed()) {
|
||||
contentTypeDisplayName = contentTypeOrError.getValue().getDisplayName()
|
||||
}
|
||||
|
||||
const fields = [
|
||||
{
|
||||
label: 'Name',
|
||||
@@ -32,7 +39,7 @@ const ConfirmCustomPackage: FunctionComponent<{
|
||||
},
|
||||
{
|
||||
label: 'Extension Type',
|
||||
value: DisplayStringForContentType(component.content_type),
|
||||
value: contentTypeDisplayName,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ import PreferencesSegment from '../../../../PreferencesComponents/PreferencesSeg
|
||||
|
||||
const loadExtensions = (application: WebApplication) =>
|
||||
application.items.getItems([
|
||||
ContentType.ActionsExtension,
|
||||
ContentType.Component,
|
||||
ContentType.Theme,
|
||||
ContentType.TYPES.ActionsExtension,
|
||||
ContentType.TYPES.Component,
|
||||
ContentType.TYPES.Theme,
|
||||
]) as AnyPackageType[]
|
||||
|
||||
type Props = {
|
||||
|
||||
@@ -104,7 +104,7 @@ const Moments: FunctionComponent<Props> = ({ application }: Props) => {
|
||||
<ItemSelectionDropdown
|
||||
onSelection={selectTag}
|
||||
placeholder="Select tag to save Moments to..."
|
||||
contentTypes={[ContentType.Tag]}
|
||||
contentTypes={[ContentType.TYPES.Tag]}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -33,7 +33,7 @@ const SmartViews = ({ application, featuresController }: Props) => {
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
const disposeItemStream = application.streamItems([ContentType.SmartView], () => {
|
||||
const disposeItemStream = application.streamItems([ContentType.TYPES.SmartView], () => {
|
||||
setSmartViews(application.items.getSmartViews().filter((view) => !isSystemView(view)))
|
||||
})
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -61,7 +61,7 @@ const Vaults = () => {
|
||||
}, [application.sharedVaults, updateAllData])
|
||||
|
||||
useEffect(() => {
|
||||
return application.streamItems([ContentType.VaultListing, ContentType.TrustedContact], () => {
|
||||
return application.streamItems([ContentType.TYPES.VaultListing, ContentType.TYPES.TrustedContact], () => {
|
||||
void updateAllData()
|
||||
})
|
||||
}, [application, updateAllData])
|
||||
|
||||
Reference in New Issue
Block a user