fix(web): archived and deleted counts on encryption panel (#1423)
* fix(web): archived and deleted counts on encryption panel * fix(snjs): yarn build snjs before e2e test suite docker builds
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
import { destroyAllObjectProperties, isDev } from '@/Utils'
|
||||
import { action, computed, makeObservable, observable, runInAction } from 'mobx'
|
||||
import { ApplicationEvent, ContentType, InternalEventBus, SNNote, SNTag } from '@standardnotes/snjs'
|
||||
import {
|
||||
ApplicationEvent,
|
||||
ContentType,
|
||||
InternalEventBus,
|
||||
SNNote,
|
||||
SNTag,
|
||||
ItemCounterInterface,
|
||||
ItemCounts,
|
||||
} from '@standardnotes/snjs'
|
||||
import { WebApplication } from '@/Application/Application'
|
||||
import { AccountMenuPane } from '@/Components/AccountMenu/AccountMenuPane'
|
||||
import { AbstractViewController } from '../Abstract/AbstractViewController'
|
||||
import { StructuredItemsCount } from './StructuredItemsCount'
|
||||
|
||||
export class AccountMenuController extends AbstractViewController {
|
||||
show = false
|
||||
@@ -28,7 +35,7 @@ export class AccountMenuController extends AbstractViewController {
|
||||
destroyAllObjectProperties(this)
|
||||
}
|
||||
|
||||
constructor(application: WebApplication, eventBus: InternalEventBus) {
|
||||
constructor(application: WebApplication, eventBus: InternalEventBus, private itemCounter: ItemCounterInterface) {
|
||||
super(application, eventBus)
|
||||
|
||||
makeObservable(this, {
|
||||
@@ -152,30 +159,7 @@ export class AccountMenuController extends AbstractViewController {
|
||||
return this.notesAndTags.length
|
||||
}
|
||||
|
||||
get structuredNotesAndTagsCount(): StructuredItemsCount {
|
||||
const count: StructuredItemsCount = {
|
||||
notes: 0,
|
||||
archived: 0,
|
||||
deleted: 0,
|
||||
tags: 0,
|
||||
}
|
||||
for (const item of this.notesAndTags) {
|
||||
if (item.archived) {
|
||||
count.archived++
|
||||
}
|
||||
|
||||
if (item.trashed) {
|
||||
count.deleted++
|
||||
}
|
||||
|
||||
if (item.content_type === ContentType.Note) {
|
||||
count.notes++
|
||||
}
|
||||
|
||||
if (item.content_type === ContentType.Tag) {
|
||||
count.tags++
|
||||
}
|
||||
}
|
||||
return count
|
||||
get structuredNotesAndTagsCount(): ItemCounts {
|
||||
return this.itemCounter.countNotesAndTags(this.notesAndTags)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export type StructuredItemsCount = {
|
||||
notes: number
|
||||
tags: number
|
||||
deleted: number
|
||||
archived: number
|
||||
}
|
||||
@@ -2,7 +2,14 @@ import { storage, StorageKey } from '@standardnotes/ui-services'
|
||||
import { WebApplication } from '@/Application/Application'
|
||||
import { AccountMenuController } from '@/Controllers/AccountMenu/AccountMenuController'
|
||||
import { destroyAllObjectProperties } from '@/Utils'
|
||||
import { ApplicationEvent, DeinitSource, WebOrDesktopDeviceInterface, InternalEventBus } from '@standardnotes/snjs'
|
||||
import {
|
||||
ApplicationEvent,
|
||||
DeinitSource,
|
||||
WebOrDesktopDeviceInterface,
|
||||
InternalEventBus,
|
||||
ItemCounterInterface,
|
||||
ItemCounter,
|
||||
} from '@standardnotes/snjs'
|
||||
import { action, makeObservable, observable } from 'mobx'
|
||||
import { ActionsMenuController } from './ActionsMenuController'
|
||||
import { FeaturesController } from './FeaturesController'
|
||||
@@ -52,10 +59,13 @@ export class ViewControllerManager {
|
||||
|
||||
private appEventObserverRemovers: (() => void)[] = []
|
||||
private eventBus: InternalEventBus
|
||||
private itemCounter: ItemCounterInterface
|
||||
|
||||
constructor(public application: WebApplication, private device: WebOrDesktopDeviceInterface) {
|
||||
this.eventBus = new InternalEventBus()
|
||||
|
||||
this.itemCounter = new ItemCounter()
|
||||
|
||||
this.selectionController = new SelectedItemsController(application, this.eventBus)
|
||||
|
||||
this.noteTagsController = new NoteTagsController(application, this.eventBus)
|
||||
@@ -90,7 +100,7 @@ export class ViewControllerManager {
|
||||
|
||||
this.noAccountWarningController = new NoAccountWarningController(application, this.eventBus)
|
||||
|
||||
this.accountMenuController = new AccountMenuController(application, this.eventBus)
|
||||
this.accountMenuController = new AccountMenuController(application, this.eventBus, this.itemCounter)
|
||||
|
||||
this.subscriptionController = new SubscriptionController(application, this.eventBus)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user