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
@@ -94,7 +94,7 @@ export class SelectedItemsController
this.disposers.push(
this.application.streamItems<SNNote | FileItem>(
[ContentType.Note, ContentType.File],
[ContentType.TYPES.Note, ContentType.TYPES.File],
({ changed, inserted, removed }) => {
runInAction(() => {
for (const removedItem of removed) {
@@ -121,7 +121,7 @@ export class SelectedItemsController
}
get selectedFiles(): FileItem[] {
return this.getFilteredSelectedItems<FileItem>(ContentType.File)
return this.getFilteredSelectedItems<FileItem>(ContentType.TYPES.File)
}
get selectedFilesCount(): number {
@@ -137,7 +137,7 @@ export class SelectedItemsController
return uuids.map((uuid) => this.application.items.findSureItem<SNNote | FileItem>(uuid)).filter((item) => !!item)
}
getFilteredSelectedItems = <T extends ListableContentItem = ListableContentItem>(contentType?: ContentType): T[] => {
getFilteredSelectedItems = <T extends ListableContentItem = ListableContentItem>(contentType?: string): T[] => {
return Object.values(this.selectedItems).filter((item) => {
return !contentType ? true : item.content_type === contentType
}) as T[]
@@ -243,9 +243,9 @@ export class SelectedItemsController
if (this.selectedItemsCount === 1) {
const item = this.firstSelectedItem
if (item.content_type === ContentType.Note) {
if (item.content_type === ContentType.TYPES.Note) {
await this.itemListController.openNote(item.uuid)
} else if (item.content_type === ContentType.File) {
} else if (item.content_type === ContentType.TYPES.File) {
await this.itemListController.openFile(item.uuid)
}