refactor: component manager usecases (#2354)

This commit is contained in:
Mo
2023-07-13 05:46:52 -05:00
committed by GitHub
parent ecc5b5e503
commit 2c68ea1d76
52 changed files with 1454 additions and 1078 deletions

View File

@@ -40,7 +40,7 @@ import {
Platform,
OutgoingItemMessagePayload,
ComponentPreferencesEntry,
ComponentOrNativeFeature,
UIFeature,
ComponentInterface,
} from '@standardnotes/models'
import { environmentToString, platformToString } from '@Lib/Application/Platforms'
@@ -52,7 +52,7 @@ import {
MessageReplyData,
ReadwriteActions,
} from './Types'
import { ComponentViewerRequiresComponentManagerFunctions } from './ComponentViewerRequiresComponentManagerFunctions'
import { ComponentViewerRequiresComponentManagerProperties } from './ComponentViewerRequiresComponentManagerFunctions'
import {
ComponentAction,
ComponentPermission,
@@ -94,7 +94,7 @@ export class ComponentViewer implements ComponentViewerInterface {
public sessionKey?: string
constructor(
private componentOrFeature: ComponentOrNativeFeature<IframeComponentFeatureDescription>,
private componentOrFeature: UIFeature<IframeComponentFeatureDescription>,
private services: {
items: ItemManagerInterface
mutator: MutatorClientInterface
@@ -111,7 +111,7 @@ export class ComponentViewer implements ComponentViewerInterface {
private config: {
environment: Environment
platform: Platform
componentManagerFunctions: ComponentViewerRequiresComponentManagerFunctions
componentManagerFunctions: ComponentViewerRequiresComponentManagerProperties
},
) {
if (isComponentViewerItemReadonlyItem(options.item)) {
@@ -152,7 +152,7 @@ export class ComponentViewer implements ComponentViewerInterface {
this.log('Constructor', this)
}
public getComponentOrFeatureItem(): ComponentOrNativeFeature<IframeComponentFeatureDescription> {
public getComponentOrFeatureItem(): UIFeature<IframeComponentFeatureDescription> {
return this.componentOrFeature
}
@@ -269,7 +269,7 @@ export class ComponentViewer implements ComponentViewerInterface {
return
}
const item = new ComponentOrNativeFeature<IframeComponentFeatureDescription>(updatedComponent)
const item = new UIFeature<IframeComponentFeatureDescription>(updatedComponent)
this.componentOrFeature = item
}
@@ -320,7 +320,7 @@ export class ComponentViewer implements ComponentViewerInterface {
},
]
this.config.componentManagerFunctions.runWithPermissions(
this.config.componentManagerFunctions.runWithPermissionsUseCase.execute(
this.componentUniqueIdentifier,
requiredPermissions,
() => {
@@ -335,7 +335,7 @@ export class ComponentViewer implements ComponentViewerInterface {
name: ComponentAction.StreamContextItem,
},
] as ComponentPermission[]
this.config.componentManagerFunctions.runWithPermissions(
this.config.componentManagerFunctions.runWithPermissionsUseCase.execute(
this.componentUniqueIdentifier,
requiredContextPermissions,
() => {
@@ -625,7 +625,7 @@ export class ComponentViewer implements ComponentViewerInterface {
content_types: types,
},
]
this.config.componentManagerFunctions.runWithPermissions(
this.config.componentManagerFunctions.runWithPermissionsUseCase.execute(
this.componentUniqueIdentifier,
requiredPermissions,
() => {
@@ -650,7 +650,7 @@ export class ComponentViewer implements ComponentViewerInterface {
},
]
this.config.componentManagerFunctions.runWithPermissions(
this.config.componentManagerFunctions.runWithPermissionsUseCase.execute(
this.componentUniqueIdentifier,
requiredPermissions,
() => {
@@ -707,7 +707,7 @@ export class ComponentViewer implements ComponentViewerInterface {
} as ComponentPermission)
}
this.config.componentManagerFunctions.runWithPermissions(
this.config.componentManagerFunctions.runWithPermissionsUseCase.execute(
this.componentUniqueIdentifier,
requiredPermissions,
@@ -830,7 +830,7 @@ export class ComponentViewer implements ComponentViewerInterface {
},
]
this.config.componentManagerFunctions.runWithPermissions(
this.config.componentManagerFunctions.runWithPermissionsUseCase.execute(
this.componentUniqueIdentifier,
requiredPermissions,
async () => {
@@ -897,7 +897,7 @@ export class ComponentViewer implements ComponentViewerInterface {
},
]
this.config.componentManagerFunctions.runWithPermissions(
this.config.componentManagerFunctions.runWithPermissionsUseCase.execute(
this.componentUniqueIdentifier,
requiredPermissions,
async () => {
@@ -934,7 +934,7 @@ export class ComponentViewer implements ComponentViewerInterface {
handleSetComponentPreferencesMessage(message: ComponentMessage): void {
const noPermissionsRequired: ComponentPermission[] = []
this.config.componentManagerFunctions.runWithPermissions(
this.config.componentManagerFunctions.runWithPermissionsUseCase.execute(
this.componentUniqueIdentifier,
noPermissionsRequired,
async () => {