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

@@ -1,4 +1,4 @@
import { UIFeature, ThemeInterface } from '@standardnotes/models'
import { UIFeature, ComponentInterface } from '@standardnotes/models'
import { ItemManagerInterface } from '@standardnotes/services'
import { NativeFeatureIdentifier, FindNativeTheme, ThemeFeatureDescription } from '@standardnotes/features'
import { Uuid } from '@standardnotes/domain-core'
@@ -54,7 +54,7 @@ export class ActiveThemeList {
for (const entry of this.list) {
if (entry instanceof Uuid) {
const theme = this.items.findItem<ThemeInterface>(entry.value)
const theme = this.items.findItem<ComponentInterface>(entry.value)
if (theme) {
const uiFeature = new UIFeature<ThemeFeatureDescription>(theme)
results.push(uiFeature)

View File

@@ -1,5 +1,5 @@
import { FindNativeTheme, GetNativeThemes, ThemeFeatureDescription } from '@standardnotes/features'
import { UIFeature, ThemeInterface } from '@standardnotes/models'
import { ComponentInterface, UIFeature } from '@standardnotes/models'
import { ItemManagerInterface } from '@standardnotes/services'
export class GetAllThemesUseCase {
@@ -15,10 +15,10 @@ export class GetAllThemesUseCase {
.getDisplayableComponents()
.filter(
(component) => component.isTheme() && FindNativeTheme(component.identifier) === undefined,
) as ThemeInterface[]
) as ComponentInterface[]
const filteredThirdPartyThemes = allThirdPartyThemes.filter((theme) => {
return options.excludeLayerable ? !theme.layerable : true
return options.excludeLayerable ? !theme.layerableTheme : true
})
return {

View File

@@ -4,8 +4,8 @@ import {
CreateDecryptedLocalStorageContextPayload,
LocalStorageDecryptedContextualPayload,
PrefKey,
ThemeInterface,
PrefDefaults,
ComponentInterface,
} from '@standardnotes/models'
import {
InternalEventBusInterface,
@@ -113,7 +113,7 @@ export class ThemeManager extends AbstractUIServicee {
for (const uuid of uuids) {
if (!this.themesActiveInTheUI.has(uuid)) {
const theme = this.application.items.findItem<ThemeInterface>(uuid.value)
const theme = this.application.items.findItem<ComponentInterface>(uuid.value)
if (theme) {
const uiFeature = new UIFeature<ThemeFeatureDescription>(theme)
this.activateTheme(uiFeature)
@@ -444,7 +444,7 @@ export class ThemeManager extends AbstractUIServicee {
for (const cachedTheme of cachedThemes) {
if ('uuid' in cachedTheme) {
const payload = this.application.items.createPayloadFromObject(cachedTheme)
const theme = this.application.items.createItemFromPayload<ThemeInterface>(payload)
const theme = this.application.items.createItemFromPayload<ComponentInterface>(payload)
features.push(new UIFeature<ThemeFeatureDescription>(theme))
} else if ('identifier' in cachedTheme) {
const feature = FindNativeTheme((cachedTheme as ThemeFeatureDescription).identifier)