fix(snjs): showing archived notes on trashed smart view (#1426)
This commit is contained in:
@@ -11,6 +11,8 @@ import {
|
|||||||
FillItemContent,
|
FillItemContent,
|
||||||
PayloadTimestampDefaults,
|
PayloadTimestampDefaults,
|
||||||
NoteContent,
|
NoteContent,
|
||||||
|
SmartView,
|
||||||
|
SystemViewId,
|
||||||
} from '@standardnotes/models'
|
} from '@standardnotes/models'
|
||||||
|
|
||||||
const setupRandomUuid = () => {
|
const setupRandomUuid = () => {
|
||||||
@@ -179,6 +181,39 @@ describe('itemManager', () => {
|
|||||||
const notes = itemManager.getDisplayableNotes()
|
const notes = itemManager.getDisplayableNotes()
|
||||||
expect(notes).toHaveLength(1)
|
expect(notes).toHaveLength(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('viewing trashed notes smart view should include archived notes', async () => {
|
||||||
|
itemManager = createService()
|
||||||
|
|
||||||
|
const archivedNote = createNote('archived')
|
||||||
|
const trashedNote = createNote('trashed')
|
||||||
|
const archivedAndTrashedNote = createNote('archived&trashed')
|
||||||
|
|
||||||
|
await itemManager.insertItems([archivedNote, trashedNote, archivedAndTrashedNote])
|
||||||
|
|
||||||
|
await itemManager.changeItem<Models.NoteMutator>(archivedNote, (m) => {
|
||||||
|
m.archived = true
|
||||||
|
})
|
||||||
|
await itemManager.changeItem<Models.NoteMutator>(trashedNote, (m) => {
|
||||||
|
m.trashed = true
|
||||||
|
})
|
||||||
|
await itemManager.changeItem<Models.NoteMutator>(archivedAndTrashedNote, (m) => {
|
||||||
|
m.trashed = true
|
||||||
|
m.archived = true
|
||||||
|
})
|
||||||
|
|
||||||
|
itemManager.setPrimaryItemDisplayOptions({
|
||||||
|
sortBy: 'title',
|
||||||
|
sortDirection: 'asc',
|
||||||
|
includeArchived: false,
|
||||||
|
includeTrashed: false,
|
||||||
|
views: [{ uuid: SystemViewId.TrashedNotes } as jest.Mocked<SmartView>],
|
||||||
|
})
|
||||||
|
|
||||||
|
const notes = itemManager.getDisplayableNotes()
|
||||||
|
|
||||||
|
expect(notes).toHaveLength(2)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('tag relationships', () => {
|
describe('tag relationships', () => {
|
||||||
|
|||||||
@@ -127,20 +127,20 @@ export class ItemManager
|
|||||||
const override: Models.FilterDisplayOptions = {}
|
const override: Models.FilterDisplayOptions = {}
|
||||||
|
|
||||||
if (options.views && options.views.find((view) => view.uuid === Models.SystemViewId.AllNotes)) {
|
if (options.views && options.views.find((view) => view.uuid === Models.SystemViewId.AllNotes)) {
|
||||||
if (options.includeArchived == undefined) {
|
if (options.includeArchived === undefined) {
|
||||||
override.includeArchived = false
|
override.includeArchived = false
|
||||||
}
|
}
|
||||||
if (options.includeTrashed == undefined) {
|
if (options.includeTrashed === undefined) {
|
||||||
override.includeTrashed = false
|
override.includeTrashed = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.views && options.views.find((view) => view.uuid === Models.SystemViewId.ArchivedNotes)) {
|
if (options.views && options.views.find((view) => view.uuid === Models.SystemViewId.ArchivedNotes)) {
|
||||||
if (options.includeTrashed == undefined) {
|
if (options.includeTrashed === undefined) {
|
||||||
override.includeTrashed = false
|
override.includeTrashed = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.views && options.views.find((view) => view.uuid === Models.SystemViewId.TrashedNotes)) {
|
if (options.views && options.views.find((view) => view.uuid === Models.SystemViewId.TrashedNotes)) {
|
||||||
if (options.includeArchived == undefined) {
|
if (!options.includeArchived) {
|
||||||
override.includeArchived = true
|
override.includeArchived = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user