fix: Fixed issue where Dark theme could be called 'Focus' in Appearance preferences

This commit is contained in:
Mo
2022-12-06 21:13:04 -06:00
parent 71675dc6a2
commit d691d7a3b3

View File

@@ -4,11 +4,19 @@ import { usePremiumModal } from '@/Hooks/usePremiumModal'
import HorizontalSeparator from '@/Components/Shared/HorizontalSeparator' import HorizontalSeparator from '@/Components/Shared/HorizontalSeparator'
import Switch from '@/Components/Switch/Switch' import Switch from '@/Components/Switch/Switch'
import { WebApplication } from '@/Application/Application' import { WebApplication } from '@/Application/Application'
import { ContentType, FeatureIdentifier, PrefKey, GetFeatures, SNTheme } from '@standardnotes/snjs' import {
ContentType,
FeatureIdentifier,
PrefKey,
GetFeatures,
SNTheme,
FindNativeFeature,
FeatureStatus,
naturalSort,
} from '@standardnotes/snjs'
import { observer } from 'mobx-react-lite' import { observer } from 'mobx-react-lite'
import { FunctionComponent, useEffect, useState } from 'react' import { FunctionComponent, useEffect, useState } from 'react'
import { Subtitle, Title, Text } from '@/Components/Preferences/PreferencesComponents/Content' import { Subtitle, Title, Text } from '@/Components/Preferences/PreferencesComponents/Content'
import { sortThemes } from '@/Utils/SortThemes'
import PreferencesPane from '../PreferencesComponents/PreferencesPane' import PreferencesPane from '../PreferencesComponents/PreferencesPane'
import PreferencesGroup from '../PreferencesComponents/PreferencesGroup' import PreferencesGroup from '../PreferencesComponents/PreferencesGroup'
import PreferencesSegment from '../PreferencesComponents/PreferencesSegment' import PreferencesSegment from '../PreferencesComponents/PreferencesSegment'
@@ -37,9 +45,8 @@ const Appearance: FunctionComponent<Props> = ({ application }) => {
useEffect(() => { useEffect(() => {
const themesAsItems: DropdownItem[] = application.items const themesAsItems: DropdownItem[] = application.items
.getDisplayableComponents() .getDisplayableComponents()
.filter((component) => component.isTheme()) .filter((component) => component.isTheme() && !(component as SNTheme).isLayerable())
.filter((component) => !(component as SNTheme).isLayerable()) .filter((theme) => !FindNativeFeature(theme.identifier))
.sort(sortThemes)
.map((theme) => { .map((theme) => {
return { return {
label: theme.name, label: theme.name,
@@ -50,13 +57,14 @@ const Appearance: FunctionComponent<Props> = ({ application }) => {
GetFeatures() GetFeatures()
.filter((feature) => feature.content_type === ContentType.Theme && !feature.layerable) .filter((feature) => feature.content_type === ContentType.Theme && !feature.layerable)
.forEach((theme) => { .forEach((theme) => {
if (themesAsItems.findIndex((item) => item.value === theme.identifier) === -1) { themesAsItems.push({
themesAsItems.push({ label: theme.name as string,
label: theme.name as string, value: theme.identifier,
value: theme.identifier, icon:
icon: PremiumFeatureIconName, application.features.getFeatureStatus(theme.identifier) !== FeatureStatus.Entitled
}) ? PremiumFeatureIconName
} : undefined,
})
}) })
themesAsItems.unshift({ themesAsItems.unshift({
@@ -64,7 +72,7 @@ const Appearance: FunctionComponent<Props> = ({ application }) => {
value: 'Default', value: 'Default',
}) })
setThemeItems(themesAsItems) setThemeItems(naturalSort(themesAsItems, 'label'))
}, [application]) }, [application])
const toggleUseDeviceSettings = () => { const toggleUseDeviceSettings = () => {