Skip to content

Commit

Permalink
feat(reader): sync defaultReaderConfig across the 3 processes (main,r…
Browse files Browse the repository at this point in the history
…eader,lib)

Will be used by the next reader setting modal PR #2032
  • Loading branch information
panaC committed Nov 16, 2023
1 parent f298911 commit ec61bea
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/common/redux/states/commonRootState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

import { ISessionState } from "readium-desktop/common/redux/states/session";
import { IKeyboardState } from "readium-desktop/common/redux/states/keyboard";
import { ReaderConfig } from "readium-desktop/common/models/reader";

export interface ICommonRootState {
session: ISessionState
keyboard: IKeyboardState;
reader: {
defaultConfig: ReaderConfig,
};
}
1 change: 1 addition & 0 deletions src/common/redux/states/renderer/readerRootState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ export interface IReaderStateReader {
mounter: TMapState<string, IHighlight>;
};
divina: IDivinaState;
defaultConfig: ReaderConfig; // sync across all app
}
2 changes: 2 additions & 0 deletions src/main/redux/middleware/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const SYNCHRONIZABLE_ACTIONS: string[] = [

catalogActions.setCatalog.ID, // send new catalogView to library
catalogActions.setTagView.ID,

readerActions.configSetDefault.ID, // readerConfig
];

export const reduxSyncMiddleware: Middleware
Expand Down
2 changes: 1 addition & 1 deletion src/main/redux/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { combineReducers } from "redux";

import { appActions, publicationActions, winActions } from "../actions";
import { lcpReducer } from "./lcp";
import { readerDefaultConfigReducer } from "./reader/defaultConfig";
import { readerDefaultConfigReducer } from "../../../common/redux/reducers/reader/defaultConfig";
import { winRegistryReaderReducer } from "./win/registry/reader";
import { winSessionLibraryReducer } from "./win/session/library";
import { winSessionReaderReducer } from "./win/session/reader";
Expand Down
5 changes: 1 addition & 4 deletions src/main/redux/states/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import { ReaderConfig, ReaderMode } from "readium-desktop/common/models/reader";
import { ReaderMode } from "readium-desktop/common/models/reader";
import { I18NState } from "readium-desktop/common/redux/states/i18n";
import { IKeyboardState } from "readium-desktop/common/redux/states/keyboard";
import { OpdsFeedDocument } from "readium-desktop/main/db/document/opds";
Expand All @@ -25,9 +25,6 @@ export interface RootState extends ICommonRootState {
// net: NetState;
i18n: I18NState;
streamer: StreamerState;
reader: {
defaultConfig: ReaderConfig,
};
// update: UpdateState;
win: {
session: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export interface IReaderRootState extends IRendererCommonRootState {
export interface IReaderStateReader {
config: ReaderConfig;
info: ReaderInfo;
defaultConfig: ReaderConfig;
}
2 changes: 2 additions & 0 deletions src/renderer/library/redux/middleware/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const SYNCHRONIZABLE_ACTIONS: string[] = [
lcpActions.unlockPublicationWithPassphrase.ID,

catalogActions.getCatalog.ID, // request to get catalog view

readerActions.configSetDefault.ID, // readerConfig
];

export const reduxSyncMiddleware = syncFactory(SYNCHRONIZABLE_ACTIONS);
4 changes: 4 additions & 0 deletions src/renderer/library/redux/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ import { RouterState } from "redux-first-history";
import { sessionReducer } from "readium-desktop/common/redux/reducers/session";
import { catalogViewReducer } from "./catalog";
import { tagReducer } from "./tag";
import { readerDefaultConfigReducer } from "readium-desktop/common/redux/reducers/reader/defaultConfig";

export const rootReducer = (routerReducer: Reducer<RouterState>) => {
return combineReducers<ILibraryRootState>({
reader: combineReducers({
defaultConfig: readerDefaultConfigReducer,
}),
session: sessionReducer,
i18n: i18nReducer,
opds: combineReducers({
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/reader/redux/middleware/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const SYNCHRONIZABLE_ACTIONS: string[] = [
readerActions.closeRequest.ID,
readerActions.detachModeRequest.ID,
readerActions.setReduxState.ID,
readerActions.configSetDefault.ID,
readerActions.configSetDefault.ID, // readerConfig
// readerActions.saveBookmarkRequest.ID,
readerActions.fullScreenRequest.ID,

Expand Down
2 changes: 2 additions & 0 deletions src/renderer/reader/redux/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ import { priorityQueueReducer } from "readium-desktop/utils/redux-reducers/pqueu
import { winModeReducer } from "readium-desktop/common/redux/reducers/winModeReducer";
import { readerDivinaReducer } from "./divina";
import { sessionReducer } from "readium-desktop/common/redux/reducers/session";
import { readerDefaultConfigReducer } from "readium-desktop/common/redux/reducers/reader/defaultConfig";

export const rootReducer = () => {
return combineReducers<IReaderRootState>({
session: sessionReducer,
api: apiReducer,
i18n: i18nReducer,
reader: combineReducers<IReaderStateReader>({ // dehydrated from main process registry (preloaded state)
defaultConfig: readerDefaultConfigReducer,
config: readerConfigReducer,
info: readerInfoReducer,
locator: readerLocatorReducer,
Expand Down

0 comments on commit ec61bea

Please sign in to comment.