internal: incomplete vault systems behind feature flag (#2340)
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
InternalEventBusInterface,
|
||||
AlertService,
|
||||
DeviceInterface,
|
||||
MutatorClientInterface,
|
||||
} from '@standardnotes/services'
|
||||
import { ItemManager } from '@Lib/Services/Items/ItemManager'
|
||||
import { SNFeaturesService } from '@Lib/Services/Features/FeaturesService'
|
||||
@@ -27,6 +28,7 @@ import { SNSyncService } from '../Sync/SyncService'
|
||||
|
||||
describe('featuresService', () => {
|
||||
let itemManager: ItemManager
|
||||
let mutator: MutatorClientInterface
|
||||
let featureService: SNFeaturesService
|
||||
let alertService: AlertService
|
||||
let syncService: SNSyncService
|
||||
@@ -52,6 +54,7 @@ describe('featuresService', () => {
|
||||
|
||||
const manager = new SNComponentManager(
|
||||
itemManager,
|
||||
mutator,
|
||||
syncService,
|
||||
featureService,
|
||||
prefsService,
|
||||
@@ -71,12 +74,14 @@ describe('featuresService', () => {
|
||||
|
||||
itemManager = {} as jest.Mocked<ItemManager>
|
||||
itemManager.getItems = jest.fn().mockReturnValue([])
|
||||
itemManager.createItem = jest.fn()
|
||||
itemManager.changeComponent = jest.fn().mockReturnValue({} as jest.Mocked<GenericItem>)
|
||||
itemManager.setItemsToBeDeleted = jest.fn()
|
||||
itemManager.addObserver = jest.fn()
|
||||
itemManager.changeItem = jest.fn()
|
||||
itemManager.changeFeatureRepo = jest.fn()
|
||||
|
||||
mutator = {} as jest.Mocked<MutatorClientInterface>
|
||||
mutator.createItem = jest.fn()
|
||||
mutator.changeComponent = jest.fn().mockReturnValue({} as jest.Mocked<GenericItem>)
|
||||
mutator.setItemsToBeDeleted = jest.fn()
|
||||
mutator.changeItem = jest.fn()
|
||||
mutator.changeFeatureRepo = jest.fn()
|
||||
|
||||
featureService = {} as jest.Mocked<SNFeaturesService>
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import {
|
||||
AlertService,
|
||||
DeviceInterface,
|
||||
isMobileDevice,
|
||||
MutatorClientInterface,
|
||||
} from '@standardnotes/services'
|
||||
|
||||
const DESKTOP_URL_PREFIX = 'sn://'
|
||||
@@ -78,6 +79,7 @@ export class SNComponentManager
|
||||
|
||||
constructor(
|
||||
private itemManager: ItemManager,
|
||||
private mutator: MutatorClientInterface,
|
||||
private syncService: SNSyncService,
|
||||
private featuresService: SNFeaturesService,
|
||||
private preferencesSerivce: SNPreferencesService,
|
||||
@@ -162,6 +164,7 @@ export class SNComponentManager
|
||||
const viewer = new ComponentViewer(
|
||||
component,
|
||||
this.itemManager,
|
||||
this.mutator,
|
||||
this.syncService,
|
||||
this.alertService,
|
||||
this.preferencesSerivce,
|
||||
@@ -482,7 +485,7 @@ export class SNComponentManager
|
||||
}
|
||||
}
|
||||
|
||||
await this.itemManager.changeItem(component, (m) => {
|
||||
await this.mutator.changeItem(component, (m) => {
|
||||
const mutator = m as ComponentMutator
|
||||
mutator.permissions = componentPermissions
|
||||
})
|
||||
@@ -546,14 +549,14 @@ export class SNComponentManager
|
||||
|
||||
const theme = this.findComponent(uuid) as SNTheme
|
||||
if (theme.active) {
|
||||
await this.itemManager.changeComponent(theme, (mutator) => {
|
||||
await this.mutator.changeComponent(theme, (mutator) => {
|
||||
mutator.active = false
|
||||
})
|
||||
} else {
|
||||
const activeThemes = this.getActiveThemes()
|
||||
|
||||
/* Activate current before deactivating others, so as not to flicker */
|
||||
await this.itemManager.changeComponent(theme, (mutator) => {
|
||||
await this.mutator.changeComponent(theme, (mutator) => {
|
||||
mutator.active = true
|
||||
})
|
||||
|
||||
@@ -562,13 +565,15 @@ export class SNComponentManager
|
||||
await sleep(10)
|
||||
for (const candidate of activeThemes) {
|
||||
if (candidate && !candidate.isLayerable()) {
|
||||
await this.itemManager.changeComponent(candidate, (mutator) => {
|
||||
await this.mutator.changeComponent(candidate, (mutator) => {
|
||||
mutator.active = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void this.syncService.sync()
|
||||
}
|
||||
|
||||
async toggleComponent(uuid: UuidString): Promise<void> {
|
||||
@@ -580,9 +585,11 @@ export class SNComponentManager
|
||||
return
|
||||
}
|
||||
|
||||
await this.itemManager.changeComponent(component, (mutator) => {
|
||||
await this.mutator.changeComponent(component, (mutator) => {
|
||||
mutator.active = !(mutator.getItem() as SNComponent).active
|
||||
})
|
||||
|
||||
void this.syncService.sync()
|
||||
}
|
||||
|
||||
isComponentActive(component: SNComponent): boolean {
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
FeatureStatus,
|
||||
FeaturesEvent,
|
||||
AlertService,
|
||||
MutatorClientInterface,
|
||||
} from '@standardnotes/services'
|
||||
import { SNFeaturesService } from '@Lib/Services'
|
||||
import {
|
||||
@@ -109,6 +110,7 @@ export class ComponentViewer implements ComponentViewerInterface {
|
||||
constructor(
|
||||
public readonly component: SNComponent,
|
||||
private itemManager: ItemManager,
|
||||
private mutator: MutatorClientInterface,
|
||||
private syncService: SNSyncService,
|
||||
private alertService: AlertService,
|
||||
private preferencesSerivce: SNPreferencesService,
|
||||
@@ -719,7 +721,7 @@ export class ComponentViewer implements ComponentViewerInterface {
|
||||
...contextualPayload,
|
||||
})
|
||||
const template = CreateDecryptedItemFromPayload(payload)
|
||||
await this.itemManager.insertItem(template)
|
||||
await this.mutator.insertItem(template)
|
||||
} else {
|
||||
if (contextualPayload.content_type !== item.content_type) {
|
||||
throw Error('Extension is trying to modify content type of item.')
|
||||
@@ -727,7 +729,7 @@ export class ComponentViewer implements ComponentViewerInterface {
|
||||
}
|
||||
}
|
||||
|
||||
await this.itemManager.changeItems(
|
||||
await this.mutator.changeItems(
|
||||
items.filter(isNotUndefined),
|
||||
(mutator) => {
|
||||
const contextualPayload = sureSearchArray(contextualPayloads, {
|
||||
@@ -798,9 +800,9 @@ export class ComponentViewer implements ComponentViewerInterface {
|
||||
})
|
||||
|
||||
const template = CreateDecryptedItemFromPayload(payload)
|
||||
const item = await this.itemManager.insertItem(template)
|
||||
const item = await this.mutator.insertItem(template)
|
||||
|
||||
await this.itemManager.changeItem(
|
||||
await this.mutator.changeItem(
|
||||
item,
|
||||
(mutator) => {
|
||||
if (responseItem.clientData) {
|
||||
@@ -857,7 +859,7 @@ export class ComponentViewer implements ComponentViewerInterface {
|
||||
void this.alertService.alert('The item you are trying to delete cannot be found.')
|
||||
continue
|
||||
}
|
||||
await this.itemManager.setItemToBeDeleted(item, PayloadEmitSource.ComponentRetrieved)
|
||||
await this.mutator.setItemToBeDeleted(item, PayloadEmitSource.ComponentRetrieved)
|
||||
}
|
||||
|
||||
void this.syncService.sync()
|
||||
@@ -875,7 +877,7 @@ export class ComponentViewer implements ComponentViewerInterface {
|
||||
handleSetComponentDataMessage(message: ComponentMessage): void {
|
||||
const noPermissionsRequired: ComponentPermission[] = []
|
||||
this.componentManagerFunctions.runWithPermissions(this.component.uuid, noPermissionsRequired, async () => {
|
||||
await this.itemManager.changeComponent(this.component, (mutator) => {
|
||||
await this.mutator.changeComponent(this.component, (mutator) => {
|
||||
mutator.componentData = message.data.componentData || {}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user