chore: fix ContentType usage (#2353)
* chore: fix ContentType usage * chore: fix specs
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { SNTag } from '@standardnotes/snjs'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { ContentType, SNTag } from '@standardnotes/snjs'
|
||||
import { InternalEventBus } from '@standardnotes/services'
|
||||
import { WebApplication } from '@/Application/WebApplication'
|
||||
import { NavigationController } from '../Navigation/NavigationController'
|
||||
@@ -57,7 +56,7 @@ describe('item list controller', () => {
|
||||
|
||||
it('should return false first item is file', () => {
|
||||
controller.getFirstNonProtectedItem = jest.fn().mockReturnValue({
|
||||
content_type: ContentType.File,
|
||||
content_type: ContentType.TYPES.File,
|
||||
})
|
||||
|
||||
expect(controller.shouldSelectFirstItem(ItemsReloadSource.UserTriggeredTagChange)).toBe(false)
|
||||
@@ -66,7 +65,7 @@ describe('item list controller', () => {
|
||||
it('should return false if selected tag is daily entry', () => {
|
||||
const tag = {
|
||||
isDailyEntry: true,
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
} as jest.Mocked<SNTag>
|
||||
|
||||
Object.defineProperty(navigationController, 'selected', {
|
||||
@@ -78,7 +77,7 @@ describe('item list controller', () => {
|
||||
|
||||
it('should return true if user triggered tag change', () => {
|
||||
const tag = {
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
} as jest.Mocked<SNTag>
|
||||
|
||||
Object.defineProperty(navigationController, 'selected', {
|
||||
@@ -90,7 +89,7 @@ describe('item list controller', () => {
|
||||
|
||||
it('should return false if not user triggered tag change and there is an existing selected item', () => {
|
||||
const tag = {
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
} as jest.Mocked<SNTag>
|
||||
|
||||
Object.defineProperty(selectionController, 'selectedUuids', {
|
||||
|
||||
@@ -109,27 +109,33 @@ export class ItemListController extends AbstractViewController implements Intern
|
||||
this.resetPagination()
|
||||
|
||||
this.disposers.push(
|
||||
application.streamItems<SNNote>([ContentType.Note, ContentType.File], () => {
|
||||
application.streamItems<SNNote>([ContentType.TYPES.Note, ContentType.TYPES.File], () => {
|
||||
void this.reloadItems(ItemsReloadSource.ItemStream)
|
||||
}),
|
||||
)
|
||||
|
||||
this.disposers.push(
|
||||
application.streamItems<SNTag>([ContentType.Tag, ContentType.SmartView], async ({ changed, inserted }) => {
|
||||
const tags = [...changed, ...inserted]
|
||||
application.streamItems<SNTag>(
|
||||
[ContentType.TYPES.Tag, ContentType.TYPES.SmartView],
|
||||
async ({ changed, inserted }) => {
|
||||
const tags = [...changed, ...inserted]
|
||||
|
||||
const { didReloadItems } = await this.reloadDisplayPreferences({ userTriggered: false })
|
||||
if (!didReloadItems) {
|
||||
/** A tag could have changed its relationships, so we need to reload the filter */
|
||||
this.reloadNotesDisplayOptions()
|
||||
void this.reloadItems(ItemsReloadSource.ItemStream)
|
||||
}
|
||||
const { didReloadItems } = await this.reloadDisplayPreferences({ userTriggered: false })
|
||||
if (!didReloadItems) {
|
||||
/** A tag could have changed its relationships, so we need to reload the filter */
|
||||
this.reloadNotesDisplayOptions()
|
||||
void this.reloadItems(ItemsReloadSource.ItemStream)
|
||||
}
|
||||
|
||||
if (this.navigationController.selected && findInArray(tags, 'uuid', this.navigationController.selected.uuid)) {
|
||||
/** Tag title could have changed */
|
||||
this.reloadPanelTitle()
|
||||
}
|
||||
}),
|
||||
if (
|
||||
this.navigationController.selected &&
|
||||
findInArray(tags, 'uuid', this.navigationController.selected.uuid)
|
||||
) {
|
||||
/** Tag title could have changed */
|
||||
this.reloadPanelTitle()
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
this.disposers.push(
|
||||
|
||||
Reference in New Issue
Block a user