refactor: merge themes into components (#2388)

This commit is contained in:
Mo
2023-08-06 08:52:19 -05:00
committed by GitHub
parent 1d60af0243
commit d2f8a36f19
33 changed files with 117 additions and 150 deletions

View File

@@ -12,7 +12,7 @@ import { SignInWithRecoveryCodes } from '../../Domain/UseCase/SignInWithRecovery
import { ListedService } from '../../Services/Listed/ListedService'
import { MigrationService } from '../../Services/Migration/MigrationService'
import { MfaService } from '../../Services/Mfa/MfaService'
import { SNComponentManager } from '../../Services/ComponentManager/ComponentManager'
import { ComponentManager } from '../../Services/ComponentManager/ComponentManager'
import { FeaturesService } from '@Lib/Services/Features/FeaturesService'
import { SettingsService } from '../../Services/Settings/SNSettingsService'
import { PreferencesService } from '../../Services/Preferences/PreferencesService'
@@ -1107,7 +1107,7 @@ export class Dependencies {
})
this.factory.set(TYPES.ComponentManager, () => {
return new SNComponentManager(
return new ComponentManager(
this.get<ItemManager>(TYPES.ItemManager),
this.get<MutatorService>(TYPES.MutatorService),
this.get<SyncService>(TYPES.SyncService),

View File

@@ -1,7 +1,7 @@
import { ApplicationStage } from '@standardnotes/services'
import { Migration } from '@Lib/Migrations/Migration'
import { ThemeInterface } from '@standardnotes/models'
import { ContentType } from '@standardnotes/domain-core'
import { ComponentInterface } from '@standardnotes/models'
const NoDistractionIdentifier = 'org.standardnotes.theme-no-distraction'
@@ -18,7 +18,7 @@ export class Migration2_42_0 extends Migration {
}
private async deleteNoDistraction(): Promise<void> {
const themes = this.services.itemManager.getItems<ThemeInterface>(ContentType.TYPES.Theme).filter((theme) => {
const themes = this.services.itemManager.getItems<ComponentInterface>(ContentType.TYPES.Theme).filter((theme) => {
return theme.identifier === NoDistractionIdentifier
})

View File

@@ -1,4 +1,4 @@
import { CompoundPredicate, Predicate, SNComponent } from '@standardnotes/models'
import { CompoundPredicate, Predicate, ComponentItem } from '@standardnotes/models'
import { Migration } from '@Lib/Migrations/Migration'
import { ApplicationStage } from '@standardnotes/services'
import { ContentType } from '@standardnotes/domain-core'
@@ -19,8 +19,8 @@ export class Migration2_7_0 extends Migration {
const batchMgrId = 'org.standardnotes.batch-manager'
const batchMgrPred = new CompoundPredicate('and', [
new Predicate<SNComponent>('content_type', '=', ContentType.TYPES.Component),
new Predicate<SNComponent>('identifier', '=', batchMgrId),
new Predicate<ComponentItem>('content_type', '=', ContentType.TYPES.Component),
new Predicate<ComponentItem>('identifier', '=', batchMgrId),
])
const batchMgrSingleton = this.services.singletonManager.findSingleton(ContentType.TYPES.Component, batchMgrPred)

View File

@@ -11,7 +11,7 @@ import {
} from '@standardnotes/services'
import { ItemManager } from '@Lib/Services/Items/ItemManager'
import { FeaturesService } from '@Lib/Services/Features/FeaturesService'
import { SNComponentManager } from './ComponentManager'
import { ComponentManager } from './ComponentManager'
import { SyncService } from '../Sync/SyncService'
import { LoggerInterface } from '@standardnotes/utils'
@@ -27,7 +27,7 @@ describe('featuresService', () => {
let logger: LoggerInterface
const createManager = (environment: Environment, platform: Platform) => {
const manager = new SNComponentManager(
const manager = new ComponentManager(
items,
mutator,
sync,

View File

@@ -69,7 +69,7 @@ declare global {
* and other components. The component manager primarily deals with iframes, and orchestrates
* sending and receiving messages to and from frames via the postMessage API.
*/
export class SNComponentManager
export class ComponentManager
extends AbstractService<ComponentManagerEvent, ComponentManagerEventData>
implements ComponentManagerInterface
{

View File

@@ -1,7 +1,7 @@
import { ItemManagerInterface, PreferenceServiceInterface } from '@standardnotes/services'
import { GetDefaultEditorIdentifier } from './GetDefaultEditorIdentifier'
import { ComponentArea, NativeFeatureIdentifier } from '@standardnotes/features'
import { SNComponent, SNTag } from '@standardnotes/models'
import { ComponentItem, SNTag } from '@standardnotes/models'
describe('getDefaultEditorIdentifier', () => {
let usecase: GetDefaultEditorIdentifier
@@ -49,7 +49,7 @@ describe('getDefaultEditorIdentifier', () => {
legacyIsDefaultEditor: jest.fn().mockReturnValue(true),
identifier: NativeFeatureIdentifier.TYPES.MarkdownProEditor,
area: ComponentArea.Editor,
} as unknown as jest.Mocked<SNComponent>
} as unknown as jest.Mocked<ComponentItem>
items.getDisplayableComponents = jest.fn().mockReturnValue([editor])

View File

@@ -13,7 +13,7 @@ import {
Environment,
PayloadTimestampDefaults,
Platform,
SNComponent,
ComponentItem,
UIFeature,
} from '@standardnotes/models'
import { DesktopManagerInterface } from '@standardnotes/services'
@@ -26,7 +26,7 @@ const nativeFeatureAsUIFeature = <F extends UIFeatureDescriptionTypes>(identifie
}
const thirdPartyFeature = () => {
const component = new SNComponent(
const component = new ComponentItem(
new DecryptedPayload({
uuid: '789',
content_type: ContentType.TYPES.Component,
@@ -101,7 +101,7 @@ describe('GetFeatureUrl', () => {
})
it('returns hosted url for third party component with no local_url', () => {
const component = new SNComponent({
const component = new ComponentItem({
uuid: '789',
content_type: ContentType.TYPES.Component,
content: {

View File

@@ -15,7 +15,6 @@ import {
FillItemContent,
PayloadEmitSource,
ComponentInterface,
ThemeInterface,
DecryptedItemInterface,
} from '@standardnotes/models'
import {
@@ -191,7 +190,7 @@ export class FeaturesService
void this.storage.setValue(StorageKey.ExperimentalFeatures, this.enabledExperimentalFeatures)
const component = this.items
.getItems<ComponentInterface | ThemeInterface>([ContentType.TYPES.Component, ContentType.TYPES.Theme])
.getItems<ComponentInterface>([ContentType.TYPES.Component, ContentType.TYPES.Theme])
.find((component) => component.identifier === identifier)
if (!component) {
return

View File

@@ -37,7 +37,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
private tagDisplayController!: Models.ItemDisplayController<Models.SNTag, Models.TagsDisplayOptions>
private itemsKeyDisplayController!: Models.ItemDisplayController<SNItemsKey>
private componentDisplayController!: Models.ItemDisplayController<Models.ComponentInterface>
private themeDisplayController!: Models.ItemDisplayController<Models.ThemeInterface>
private themeDisplayController!: Models.ItemDisplayController<Models.ComponentInterface>
private fileDisplayController!: Models.ItemDisplayController<Models.FileItem>
private smartViewDisplayController!: Models.ItemDisplayController<Models.SmartView>
@@ -225,7 +225,7 @@ export class ItemManager extends Services.AbstractService implements Services.It
return this.itemsKeyDisplayController.items()
}
public getDisplayableComponents(): (Models.ComponentInterface | Models.ThemeInterface)[] {
public getDisplayableComponents(): Models.ComponentInterface[] {
return [...this.componentDisplayController.items(), ...this.themeDisplayController.items()]
}