Skip to content

Commit

Permalink
BugFix: Setting Color Theme In Book SettingsBar Saves Selected Theme
Browse files Browse the repository at this point in the history
  • Loading branch information
btpf committed May 4, 2024
1 parent 36155ce commit 8221c77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import styles from './ThemesContainer.module.scss'
import { useAppDispatch, useAppSelector } from '@store/hooks'
import { Theme } from '@store/slices/EpubJSBackend/data/theme/themeManager.d';
import { setThemeThunk } from '@store/slices/EpubJSBackend/data/theme/themeManager';
import { setSelectedTheme } from '@store/slices/appState';

interface ThemeInterface{
[name: string]: Theme
Expand All @@ -30,6 +31,10 @@ const ThemesContainer = ()=>{
const {background, color} = (appThemes[item].reader).body
return (
<div key={item} onClick={()=>{
// This will select and save the global theme.
dispatch(setSelectedTheme(item))

// Below will simply update the rendition themes.
if(isDualReaderMode){
dispatch(setThemeThunk({themeName: item, view:0}))
dispatch(setThemeThunk({themeName: item, view:1}))
Expand Down
3 changes: 2 additions & 1 deletion src/store/slices/appState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export const appState = createSlice({
},
extraReducers(builder) {
builder.addCase(setThemeThunk.pending, (state, action)=>{
state.selectedTheme = action.meta.arg.themeName
// We will comment this out for consistency, since the bookstate setThemeThunk should not set the global app theme.
// state.selectedTheme = action.meta.arg.themeName
})
},
})
Expand Down

0 comments on commit 8221c77

Please sign in to comment.