Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,6 +34,7 @@ import {
subscribeSafariPushBrowser,
Permission
} from 'utils/browserNotifications'
import { THEME_KEY } from 'utils/theme/theme'
import { withClassNullGuard } from 'utils/withNullGuard'

import { SettingsPageProps as DesktopSettingsPageProps } from './components/desktop/SettingsPage'
Expand DownExpand Up@@ -248,7 +249,12 @@ function makeMapStateToProps() {

function mapDispatchToProps(dispatch: Dispatch) {
return {
setTheme: (theme: any) => dispatch(setTheme({ theme })),
setTheme: (theme: any) => {
dispatch(setTheme({ theme }))
if (typeof window !== 'undefined') {
window.localStorage.setItem(THEME_KEY, theme)
}
},
getNotificationSettings: () =>
dispatch(settingPageActions.getNotificationSettings()),
getPushNotificationSettings: () =>
Expand Down
8 changes: 1 addition & 7 deletions packages/web/src/utils/theme/theme.ts
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { SystemAppearance, Theme } from '@audius/common/models'

const THEME_KEY = 'theme'
export const THEME_KEY = 'theme'
export const PREFERS_DARK_MEDIA_QUERY = '(prefers-color-scheme: dark)'

export const doesPreferDarkMode = () => {
Expand All@@ -18,12 +18,6 @@ export const shouldShowDark = (theme?: Theme | null) => {
)
}

export const setTheme = (theme: Theme) => {
if (typeof window !== 'undefined') {
window.localStorage.setItem(THEME_KEY, theme)
}
}

export const getTheme = (): Theme | null => {
const theme =
typeof window !== 'undefined'
Expand Down