remove unnecessary casts

This commit is contained in:
Peter Clement 2025-01-06 12:43:15 +00:00
parent 428df339c4
commit a09caf52d8
2 changed files with 5 additions and 14 deletions

View File

@ -19,10 +19,7 @@ export class ThemeStore extends BudiStore<ThemeState> {
syncAppTheme = (app: App) => { syncAppTheme = (app: App) => {
this.update(state => { this.update(state => {
const theme = ensureValidTheme( const theme = ensureValidTheme(app.theme, DefaultAppTheme)
app.theme as Theme | undefined,
DefaultAppTheme
) as Theme
return { return {
...state, ...state,
theme, theme,
@ -35,10 +32,7 @@ export class ThemeStore extends BudiStore<ThemeState> {
const app = await API.saveAppMetadata(appId, { theme }) const app = await API.saveAppMetadata(appId, { theme })
this.update(state => ({ this.update(state => ({
...state, ...state,
theme: ensureValidTheme( theme: ensureValidTheme(app.theme, DefaultAppTheme),
app.theme as Theme | undefined,
DefaultAppTheme
) as Theme,
})) }))
} }
@ -55,10 +49,7 @@ export class ThemeStore extends BudiStore<ThemeState> {
const { theme, customTheme } = metadata const { theme, customTheme } = metadata
this.update(state => ({ this.update(state => ({
...state, ...state,
theme: ensureValidTheme( theme: ensureValidTheme(theme, DefaultAppTheme),
theme as Theme | undefined,
DefaultAppTheme
) as Theme,
customTheme: customTheme || {}, customTheme: customTheme || {},
})) }))
} }

View File

@ -1,4 +1,4 @@
import { User, Document, Plugin, Snippet } from "../" import { User, Document, Plugin, Snippet, Theme } from "../"
import { SocketSession } from "../../sdk" import { SocketSession } from "../../sdk"
export type AppMetadataErrors = { [key: string]: string[] } export type AppMetadataErrors = { [key: string]: string[] }
@ -14,7 +14,7 @@ export interface App extends Document {
instance: AppInstance instance: AppInstance
tenantId: string tenantId: string
status: string status: string
theme?: string theme?: Theme
customTheme?: AppCustomTheme customTheme?: AppCustomTheme
revertableVersion?: string revertableVersion?: string
lockedBy?: User lockedBy?: User