Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unused dark mode code #2332

Merged
merged 1 commit into from May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/models/src/Domain/Syncable/UserPrefs/PrefKey.ts
Expand Up @@ -40,7 +40,6 @@ export enum PrefKey {
NewNoteTitleFormat = 'newNoteTitleFormat',
CustomNoteTitleFormat = 'customNoteTitleFormat',
UpdateSavingStatusIndicator = 'updateSavingStatusIndicator',
DarkMode = 'darkMode',
DefaultEditorIdentifier = 'defaultEditorIdentifier',
MomentsDefaultTagUuid = 'momentsDefaultTagUuid',
ClipperDefaultTagUuid = 'clipperDefaultTagUuid',
Expand Down Expand Up @@ -118,7 +117,6 @@ export type PrefValue = {
[PrefKey.EditorLineWidth]: EditorLineWidth
[PrefKey.EditorFontSize]: EditorFontSize
[PrefKey.UpdateSavingStatusIndicator]: boolean
[PrefKey.DarkMode]: boolean
[PrefKey.DefaultEditorIdentifier]: EditorIdentifier
[PrefKey.MomentsDefaultTagUuid]: string | undefined
[PrefKey.ClipperDefaultTagUuid]: string | undefined
Expand Down
3 changes: 0 additions & 3 deletions packages/ui-services/src/Theme/ThemeManager.ts
Expand Up @@ -249,7 +249,6 @@ export class ThemeManager extends AbstractService {
const setTheme = () => {
if (themeIdentifier === DefaultThemeIdentifier) {
toggleActiveTheme()
void this.application.setPreference(PrefKey.DarkMode, false)
} else {
const theme = themes.find((theme) => theme.package_info.identifier === themeIdentifier)
if (theme && !theme.active) {
Expand Down Expand Up @@ -345,8 +344,6 @@ export class ThemeManager extends AbstractService {
}
}
document.getElementsByTagName('head')[0].appendChild(link)

void this.application.setPreference(PrefKey.DarkMode, false)
}

private getBackgroundColor() {
Expand Down
Expand Up @@ -22,7 +22,6 @@ import FileDragNDropProvider from '../FileDragNDropProvider'
import ResponsivePaneProvider from '../Panes/ResponsivePaneProvider'
import AndroidBackHandlerProvider from '@/NativeMobileWeb/useAndroidBackHandler'
import ConfirmDeleteAccountContainer from '@/Components/ConfirmDeleteAccountModal/ConfirmDeleteAccountModal'
import DarkModeHandler from '../DarkModeHandler/DarkModeHandler'
import ApplicationProvider from '../ApplicationProvider'
import CommandProvider from '../CommandProvider'
import PanesSystemComponent from '../Panes/PanesSystemComponent'
Expand Down Expand Up @@ -216,7 +215,6 @@ const ApplicationView: FunctionComponent<Props> = ({ application, mainApplicatio
<ApplicationProvider application={application}>
<CommandProvider service={application.keyboardService}>
<AndroidBackHandlerProvider application={application}>
<DarkModeHandler application={application} />
<ResponsivePaneProvider paneController={application.getViewControllerManager().paneController}>
<PremiumModalProvider
application={application}
Expand Down

This file was deleted.

@@ -1,13 +1,5 @@
import { WebApplication } from '@/Application/WebApplication'
import {
ApplicationEvent,
ComponentArea,
ContentType,
FeatureIdentifier,
GetFeatures,
PrefKey,
SNComponent,
} from '@standardnotes/snjs'
import { ComponentArea, ContentType, FeatureIdentifier, GetFeatures, SNComponent } from '@standardnotes/snjs'
import { observer } from 'mobx-react-lite'
import { FunctionComponent, useCallback, useEffect, useRef, useState } from 'react'
import Icon from '@/Components/Icon/Icon'
Expand All @@ -18,7 +10,6 @@ import { sortThemes } from '@/Utils/SortThemes'
import HorizontalSeparator from '../Shared/HorizontalSeparator'
import { QuickSettingsController } from '@/Controllers/QuickSettingsController'
import PanelSettingsSection from './PanelSettingsSection'
import { PrefDefaults } from '@/Constants/PrefDefaults'
import Menu from '../Menu/Menu'
import MenuSwitchButtonItem from '../Menu/MenuSwitchButtonItem'
import MenuRadioButtonItem from '../Menu/MenuRadioButtonItem'
Expand All @@ -34,24 +25,7 @@ const QuickSettingsMenu: FunctionComponent<MenuProps> = ({ application, quickSet
const [themes, setThemes] = useState<ThemeItem[]>([])
const [toggleableComponents, setToggleableComponents] = useState<SNComponent[]>([])

const [isDarkModeOn, setDarkModeOn] = useState(() =>
application.getPreference(PrefKey.DarkMode, PrefDefaults[PrefKey.DarkMode]),
)
const defaultThemeOn =
!themes.map((item) => item?.component).find((theme) => theme?.active && !theme.isLayerable()) && !isDarkModeOn

useEffect(() => {
const removeObserver = application.addEventObserver(async (event) => {
if (event !== ApplicationEvent.PreferencesChanged) {
return
}

const isDarkModeOn = application.getPreference(PrefKey.DarkMode, PrefDefaults[PrefKey.DarkMode])
setDarkModeOn(isDarkModeOn)
})

return removeObserver
}, [application])
const defaultThemeOn = !themes.map((item) => item?.component).find((theme) => theme?.active && !theme.isLayerable())

const prefsButtonRef = useRef<HTMLButtonElement>(null)
const defaultThemeButtonRef = useRef<HTMLButtonElement>(null)
Expand Down Expand Up @@ -145,8 +119,7 @@ const QuickSettingsMenu: FunctionComponent<MenuProps> = ({ application, quickSet

const toggleDefaultTheme = useCallback(() => {
deactivateAnyNonLayerableTheme()
void application.setPreference(PrefKey.DarkMode, false)
}, [application, deactivateAnyNonLayerableTheme])
}, [deactivateAnyNonLayerableTheme])

return (
<Menu a11yLabel="Quick settings menu" isOpen>
Expand Down
1 change: 0 additions & 1 deletion packages/web/src/javascripts/Constants/PrefDefaults.ts
Expand Up @@ -36,6 +36,5 @@ export const PrefDefaults = {
[PrefKey.NewNoteTitleFormat]: NewNoteTitleFormat.CurrentDateAndTime,
[PrefKey.CustomNoteTitleFormat]: 'YYYY-MM-DD [at] hh:mm A',
[PrefKey.UpdateSavingStatusIndicator]: true,
[PrefKey.DarkMode]: false,
[PrefKey.PaneGesturesEnabled]: true,
} as const