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

@@ -1383,7 +1383,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
}
private createItemManager() {
this.itemManager = new InternalServices.ItemManager(this.payloadManager, this.options, this.internalEventBus)
this.itemManager = new InternalServices.ItemManager(this.payloadManager, this.internalEventBus)
this.services.push(this.itemManager)
}

View File

@@ -1,11 +1,9 @@
import { ApplicationDisplayOptions, ApplicationSyncOptions } from './OptionalOptions'
import { ApplicationSyncOptions } from './OptionalOptions'
export interface ApplicationOptionsWhichHaveDefaults {
loadBatchSize: ApplicationSyncOptions['loadBatchSize']
supportsFileNavigation: ApplicationDisplayOptions['supportsFileNavigation']
}
export const ApplicationOptionsDefaults: ApplicationOptionsWhichHaveDefaults = {
loadBatchSize: 700,
supportsFileNavigation: false,
}

View File

@@ -5,9 +5,8 @@ export interface ApplicationSyncOptions {
loadBatchSize: number
}
export interface ApplicationDisplayOptions {
supportsFileNavigation: boolean
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ApplicationDisplayOptions {}
export interface ApplicationOptionalConfiguratioOptions {
/**

View File

@@ -83,6 +83,7 @@ export class SNActionsService extends AbstractService {
;(this.challengeService as unknown) = undefined
;(this.protocolService as unknown) = undefined
;(this.syncService as unknown) = undefined
this.payloadRequestHandlers.length = 0
this.previousPasswords.length = 0
super.deinit()
}

View File

@@ -49,7 +49,7 @@ describe('itemManager', () => {
let internalEventBus: InternalEventBusInterface
const createService = () => {
return new ItemManager(payloadManager, { supportsFileNavigation: false }, internalEventBus)
return new ItemManager(payloadManager, internalEventBus)
}
beforeEach(() => {

View File

@@ -8,7 +8,6 @@ import * as Models from '@standardnotes/models'
import * as Services from '@standardnotes/services'
import { PayloadManagerChangeData } from '../Payloads'
import { DiagnosticInfo, ItemsClientInterface, ItemRelationshipDirection } from '@standardnotes/services'
import { ApplicationDisplayOptions } from '@Lib/Application/Options/OptionalOptions'
import { CollectionSort, DecryptedItemInterface, ItemContent, SmartViewDefaultIconName } from '@standardnotes/models'
type ItemsChangeObserver<I extends Models.DecryptedItemInterface = Models.DecryptedItemInterface> = {
@@ -44,7 +43,6 @@ export class ItemManager
constructor(
private payloadManager: PayloadManager,
private readonly options: ApplicationDisplayOptions = { supportsFileNavigation: false },
protected override internalEventBus: Services.InternalEventBusInterface,
) {
super(internalEventBus)
@@ -55,7 +53,7 @@ export class ItemManager
}
private rebuildSystemSmartViews(criteria: Models.FilterDisplayOptions): Models.SmartView[] {
this.systemSmartViews = Models.BuildSmartViews(criteria, this.options)
this.systemSmartViews = Models.BuildSmartViews(criteria)
return this.systemSmartViews
}
@@ -68,7 +66,7 @@ export class ItemManager
{
sortBy: 'created_at',
sortDirection: 'dsc',
hiddenContentTypes: !this.options.supportsFileNavigation ? [ContentType.File] : [],
hiddenContentTypes: [],
},
)
this.tagDisplayController = new Models.ItemDisplayController(this.collection, [ContentType.Tag], {
@@ -184,12 +182,7 @@ export class ItemManager
public getDisplayableNotes(): Models.SNNote[] {
assert(this.navigationDisplayController.contentTypes.length === 2)
const fileContentTypeHidden = !this.options.supportsFileNavigation
if (fileContentTypeHidden) {
return this.navigationDisplayController.items() as Models.SNNote[]
} else {
return this.navigationDisplayController.items().filter(Models.isNote)
}
return this.navigationDisplayController.items().filter(Models.isNote)
}
public getDisplayableFiles(): Models.FileItem[] {
@@ -197,7 +190,6 @@ export class ItemManager
}
public getDisplayableNotesAndFiles(): (Models.SNNote | Models.FileItem)[] {
assert(this.options.supportsFileNavigation)
return this.navigationDisplayController.items()
}
@@ -215,7 +207,6 @@ export class ItemManager
public override deinit(): void {
this.unsubChangeObserver()
;(this.options as unknown) = undefined
;(this.unsubChangeObserver as unknown) = undefined
;(this.payloadManager as unknown) = undefined
;(this.collection as unknown) = undefined
@@ -292,6 +283,10 @@ export class ItemManager
return this.tagItemsIndex.allCountableNotesCount()
}
public allCountableFilesCount(): number {
return this.tagItemsIndex.allCountableFilesCount()
}
public countableNotesForTag(tag: Models.SNTag | Models.SmartView): number {
if (tag instanceof Models.SmartView) {
if (tag.uuid === Models.SystemViewId.AllNotes) {

View File

@@ -36,7 +36,7 @@ describe('mutator service', () => {
internalEventBus.publish = jest.fn()
payloadManager = new PayloadManager(internalEventBus)
itemManager = new ItemManager(payloadManager, { supportsFileNavigation: false }, internalEventBus)
itemManager = new ItemManager(payloadManager, internalEventBus)
mutatorService = new MutatorService(
itemManager,