fix(services): counting trashed and archived items

This commit is contained in:
Karol Sójko
2022-08-23 13:20:34 +02:00
parent a2b6ec74b0
commit 7bff3dee24
2 changed files with 9 additions and 5 deletions

View File

@@ -13,6 +13,10 @@ describe('ItemCounter', () => {
{
trashed: true,
} as jest.Mocked<SNNote>,
{
archived: true,
trashed: true,
} as jest.Mocked<SNNote>,
{
content_type: ContentType.Note,
} as jest.Mocked<SNNote>,
@@ -23,7 +27,7 @@ describe('ItemCounter', () => {
expect(createCounter().countNotesAndTags(items)).toEqual({
archived: 1,
deleted: 1,
deleted: 2,
notes: 1,
tags: 1,
})

View File

@@ -13,13 +13,13 @@ export class ItemCounter implements ItemCounterInterface {
}
for (const item of items) {
if (item.archived) {
counts.archived++
if (item.trashed) {
counts.deleted++
continue
}
if (item.trashed) {
counts.deleted++
if (item.archived) {
counts.archived++
continue
}