feat: display number of files for 'Files' view (#2065)

* feat: display number of files for 'Files' view

* feat: include files count in Preferences > Security
This commit is contained in:
Mo
2022-11-28 15:38:50 -06:00
committed by GitHub
parent 052e7d2f90
commit 767d354780
25 changed files with 69 additions and 91 deletions

View File

@@ -1,14 +1,6 @@
import { destroyAllObjectProperties, isDev } from '@/Utils'
import { action, computed, makeObservable, observable, runInAction } from 'mobx'
import {
ApplicationEvent,
ContentType,
InternalEventBus,
SNNote,
SNTag,
ItemCounterInterface,
ItemCounts,
} from '@standardnotes/snjs'
import { ApplicationEvent, ContentType, InternalEventBus, SNNote, SNTag } from '@standardnotes/snjs'
import { WebApplication } from '@/Application/Application'
import { AccountMenuPane } from '@/Components/AccountMenu/AccountMenuPane'
import { AbstractViewController } from '../Abstract/AbstractViewController'
@@ -36,7 +28,7 @@ export class AccountMenuController extends AbstractViewController {
destroyAllObjectProperties(this)
}
constructor(application: WebApplication, eventBus: InternalEventBus, private itemCounter: ItemCounterInterface) {
constructor(application: WebApplication, eventBus: InternalEventBus) {
super(application, eventBus)
makeObservable(this, {
@@ -165,8 +157,4 @@ export class AccountMenuController extends AbstractViewController {
get notesAndTagsCount(): number {
return this.notesAndTags.length
}
get structuredNotesAndTagsCount(): ItemCounts {
return this.itemCounter.countNotesAndTags(this.notesAndTags)
}
}

View File

@@ -34,6 +34,7 @@ export class NavigationController
smartViews: SmartView[] = []
starredTags: SNTag[] = []
allNotesCount_ = 0
allFilesCount_ = 0
selectedUuid: AnyTag['uuid'] | undefined = undefined
selected_: AnyTag | undefined = undefined
selectedLocation: TagListSectionType | undefined = undefined
@@ -62,8 +63,11 @@ export class NavigationController
starredTags: observable,
smartViews: observable.ref,
allNotesCount_: observable,
allFilesCount_: observable,
allNotesCount: computed,
allFilesCount: computed,
setAllNotesCount: action,
setAllFilesCount: action,
selected_: observable,
selectedLocation: observable,
@@ -135,6 +139,7 @@ export class NavigationController
this.application.items.addNoteCountChangeObserver((tagUuid) => {
if (!tagUuid) {
this.setAllNotesCount(this.application.items.allCountableNotesCount())
this.setAllFilesCount(this.application.items.allCountableFilesCount())
} else {
const tag = this.application.items.findItem<SNTag>(tagUuid)
if (tag) {
@@ -411,6 +416,14 @@ export class NavigationController
this.allNotesCount_ = allNotesCount
}
setAllFilesCount(allFilesCount: number) {
this.allFilesCount_ = allFilesCount
}
public get allFilesCount(): number {
return this.allFilesCount_
}
public get allNotesCount(): number {
return this.allNotesCount_
}

View File

@@ -14,8 +14,6 @@ import {
DeinitSource,
WebOrDesktopDeviceInterface,
InternalEventBus,
ItemCounterInterface,
ItemCounter,
SubscriptionClientInterface,
InternalEventHandlerInterface,
InternalEventInterface,
@@ -74,7 +72,6 @@ export class ViewControllerManager implements InternalEventHandlerInterface {
private appEventObserverRemovers: (() => void)[] = []
private eventBus: InternalEventBus
private itemCounter: ItemCounterInterface
private subscriptionManager: SubscriptionClientInterface
private persistenceService: PersistenceService
private applicationEventObserver: EventObserverInterface
@@ -88,8 +85,6 @@ export class ViewControllerManager implements InternalEventHandlerInterface {
this.eventBus.addEventHandler(this, CrossControllerEvent.HydrateFromPersistedValues)
this.eventBus.addEventHandler(this, CrossControllerEvent.RequestValuePersistence)
this.itemCounter = new ItemCounter()
this.subscriptionManager = application.subscriptions
this.quickSettingsMenuController = new QuickSettingsController(application, this.eventBus)
@@ -135,7 +130,7 @@ export class ViewControllerManager implements InternalEventHandlerInterface {
this.noAccountWarningController = new NoAccountWarningController(application, this.eventBus)
this.accountMenuController = new AccountMenuController(application, this.eventBus, this.itemCounter)
this.accountMenuController = new AccountMenuController(application, this.eventBus)
this.subscriptionController = new SubscriptionController(application, this.eventBus, this.subscriptionManager)