Skip to content

Commit

Permalink
refactor(API): switch catalog/get API to redux/redux-saga logic
Browse files Browse the repository at this point in the history
(Fixes #1993)

I improve the catalogView update to not always re-render it when setReduxState from reader is dispatched.
It appears that setReduxState is lot of time dispatched across the app to keep the readingLocation synchronized beetween the main process and renderer process
  • Loading branch information
panaC committed Sep 7, 2023
1 parent 2374d85 commit 50cc655
Show file tree
Hide file tree
Showing 20 changed files with 398 additions and 293 deletions.
2 changes: 0 additions & 2 deletions src/common/api/api.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import { ICatalogModuleApi } from "./interface/catalog.interface";
import { IOpdsModuleApi } from "./interface/opdsApi.interface";
import { IApiappModuleApi } from "./interface/apiappApi.interface";
import { IHttpBrowserModuleApi } from "./interface/httpBrowser.interface";
import { IPublicationModuleApi } from "./interface/publicationApi.interface";

export type TApiMethod =
ICatalogModuleApi &
IOpdsModuleApi &
IApiappModuleApi &
IHttpBrowserModuleApi &
Expand Down
22 changes: 0 additions & 22 deletions src/common/api/interface/catalog.interface.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/common/api/methodApi.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
// ==LICENSE-END==

import { IHttpBrowserApi } from "./interface/httpBrowser.interface";
import { ICatalogApi } from "./interface/catalog.interface";
import { IOpdsApi } from "./interface/opdsApi.interface";
import { IPublicationApi } from "./interface/publicationApi.interface";
import { IApiappApi } from "./interface/apiappApi.interface";

export type TMethodApi =
keyof ICatalogApi |
keyof IPublicationApi |
keyof IOpdsApi |
keyof IApiappApi |
Expand Down
2 changes: 0 additions & 2 deletions src/common/api/moduleApi.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
// ==LICENSE-END==

// module typing
type TCatalogApi = "catalog";
type TPublicationApi = "publication";
type TOpdsApi = "opds";
type TApiappApi = "apiapp";
type THttpBrowserApi = "httpbrowser";
export type TModuleApi =
TCatalogApi |
TPublicationApi |
TOpdsApi |
TApiappApi |
Expand Down
25 changes: 25 additions & 0 deletions src/common/redux/actions/catalog/getCatalog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ==LICENSE-BEGIN==
// Copyright 2017 European Digital Reading Lab. All rights reserved.
// Licensed to the Readium Foundation under one or more contributor license agreements.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import { Action } from "readium-desktop/common/models/redux";

export const ID = "CATALOG_GET";

export interface Payload {
}

export function build():
Action<typeof ID, Payload> {

return {
type: ID,
payload: {
},
};
}
build.toString = () => ID; // Redux StringableActionCreator
export type TAction = ReturnType<typeof build>;
14 changes: 14 additions & 0 deletions src/common/redux/actions/catalog/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// ==LICENSE-BEGIN==
// Copyright 2017 European Digital Reading Lab. All rights reserved.
// Licensed to the Readium Foundation under one or more contributor license agreements.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import * as getCatalog from "./getCatalog";
import * as setCatalog from "./setCatalog";

export {
getCatalog,
setCatalog,
};
28 changes: 28 additions & 0 deletions src/common/redux/actions/catalog/setCatalog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// ==LICENSE-BEGIN==
// Copyright 2017 European Digital Reading Lab. All rights reserved.
// Licensed to the Readium Foundation under one or more contributor license agreements.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file exposed on Github (readium) in the project repository.
// ==LICENSE-END==

import { Action } from "readium-desktop/common/models/redux";
import { CatalogView } from "readium-desktop/common/views/catalog";

export const ID = "CATALOG_SET_VIEW";

export interface Payload {
catalogView: CatalogView;
}

export function build(catalogView: CatalogView):
Action<typeof ID, Payload> {

return {
type: ID,
payload: {
catalogView,
},
};
}
build.toString = () => ID; // Redux StringableActionCreator
export type TAction = ReturnType<typeof build>;
2 changes: 2 additions & 0 deletions src/common/redux/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as netActions from "./net/";
import * as readerActions from "./reader/";
import * as toastActions from "./toast/";
import * as sessionActions from "./session/";
import * as catalogActions from "./catalog";

export {
historyActions,
Expand All @@ -35,4 +36,5 @@ export {
keyboardActions,
loadActions,
sessionActions,
catalogActions,
};
249 changes: 0 additions & 249 deletions src/main/api/catalog.ts

This file was deleted.

Loading

0 comments on commit 50cc655

Please sign in to comment.