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

@@ -1,5 +1,5 @@
import { FileItem } from '@standardnotes/models'
import { ContentType } from '@standardnotes/common'
import { ContentType } from '@standardnotes/domain-core'
import { SNApplication } from '@standardnotes/snjs'
import { ItemViewControllerInterface } from './ItemViewControllerInterface'
@@ -23,20 +23,23 @@ export class FileViewController implements ItemViewControllerInterface {
}
private streamItems() {
this.removeStreamObserver = this.application.streamItems<FileItem>(ContentType.File, ({ changed, inserted }) => {
if (this.dealloced) {
return
}
this.removeStreamObserver = this.application.streamItems<FileItem>(
ContentType.TYPES.File,
({ changed, inserted }) => {
if (this.dealloced) {
return
}
const files = changed.concat(inserted)
const files = changed.concat(inserted)
const matchingFile = files.find((item) => {
return item.uuid === this.item.uuid
})
const matchingFile = files.find((item) => {
return item.uuid === this.item.uuid
})
if (matchingFile) {
this.item = matchingFile
}
})
if (matchingFile) {
this.item = matchingFile
}
},
)
}
}

View File

@@ -1,5 +1,5 @@
import { WebApplication } from '@/Application/WebApplication'
import { ContentType } from '@standardnotes/common'
import { ContentType } from '@standardnotes/domain-core'
import {
MutatorService,
SNComponentManager,
@@ -47,7 +47,7 @@ describe('note view controller', () => {
await controller.initialize()
expect(application.items.createTemplateItem).toHaveBeenCalledWith(
ContentType.Note,
ContentType.TYPES.Note,
expect.objectContaining({ noteType: NoteType.Plain }),
expect.anything(),
)
@@ -68,7 +68,7 @@ describe('note view controller', () => {
await controller.initialize()
expect(application.items.createTemplateItem).toHaveBeenCalledWith(
ContentType.Note,
ContentType.TYPES.Note,
expect.objectContaining({ noteType: NoteType.Markdown }),
expect.anything(),
)

View File

@@ -11,7 +11,7 @@ import {
} from '@standardnotes/models'
import { UuidString } from '@standardnotes/snjs'
import { removeFromArray } from '@standardnotes/utils'
import { ContentType } from '@standardnotes/common'
import { ContentType } from '@standardnotes/domain-core'
import { ItemViewControllerInterface } from './ItemViewControllerInterface'
import { TemplateNoteViewControllerOptions } from './TemplateNoteViewControllerOptions'
import { log, LoggingDomain } from '@/Logging'
@@ -99,7 +99,7 @@ export class NoteViewController implements ItemViewControllerInterface {
const noteType = noteTypeForEditorIdentifier(editorIdentifier)
const note = this.application.items.createTemplateItem<NoteContent, SNNote>(
ContentType.Note,
ContentType.TYPES.Note,
{
text: '',
title: this.templateNoteOptions?.title || '',
@@ -140,7 +140,7 @@ export class NoteViewController implements ItemViewControllerInterface {
}
this.disposers.push(
this.application.streamItems<SNNote>(ContentType.Note, ({ changed, inserted, source }) => {
this.application.streamItems<SNNote>(ContentType.TYPES.Note, ({ changed, inserted, source }) => {
if (this.dealloced) {
return
}