fix(snjs): showing archived notes on trashed smart view (#1426)
This commit is contained in:
@@ -11,6 +11,8 @@ import {
|
||||
FillItemContent,
|
||||
PayloadTimestampDefaults,
|
||||
NoteContent,
|
||||
SmartView,
|
||||
SystemViewId,
|
||||
} from '@standardnotes/models'
|
||||
|
||||
const setupRandomUuid = () => {
|
||||
@@ -179,6 +181,39 @@ describe('itemManager', () => {
|
||||
const notes = itemManager.getDisplayableNotes()
|
||||
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', () => {
|
||||
|
||||
@@ -127,20 +127,20 @@ export class ItemManager
|
||||
const override: Models.FilterDisplayOptions = {}
|
||||
|
||||
if (options.views && options.views.find((view) => view.uuid === Models.SystemViewId.AllNotes)) {
|
||||
if (options.includeArchived == undefined) {
|
||||
if (options.includeArchived === undefined) {
|
||||
override.includeArchived = false
|
||||
}
|
||||
if (options.includeTrashed == undefined) {
|
||||
if (options.includeTrashed === undefined) {
|
||||
override.includeTrashed = false
|
||||
}
|
||||
}
|
||||
if (options.views && options.views.find((view) => view.uuid === Models.SystemViewId.ArchivedNotes)) {
|
||||
if (options.includeTrashed == undefined) {
|
||||
if (options.includeTrashed === undefined) {
|
||||
override.includeTrashed = false
|
||||
}
|
||||
}
|
||||
if (options.views && options.views.find((view) => view.uuid === Models.SystemViewId.TrashedNotes)) {
|
||||
if (options.includeArchived == undefined) {
|
||||
if (!options.includeArchived) {
|
||||
override.includeArchived = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user