Skip to content

Commit

Permalink
fix(opds): reset opds header links at each opds location changed and …
Browse files Browse the repository at this point in the history
…replace header links during opds navigation, no accumulation. Fixes #2017
  • Loading branch information
panaC committed Oct 2, 2023
1 parent 23fdd65 commit 51914df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/renderer/library/redux/reducers/opds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function opdsHeaderLinkReducer(
): IOpdsHeaderState {
switch (action.type) {
case headerLinksUpdate.ID:
const stateNew = { ...state };
const stateNew: IOpdsHeaderState = {};
for (const key of ObjectKeys(action.payload)) {
stateNew[key] = action.payload[key];
}
Expand Down
17 changes: 11 additions & 6 deletions src/renderer/library/redux/sagas/opds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ const debug = debug_("readium-desktop:renderer:redux:saga:opds");
function* browseWatcher(action: routerActions.locationChanged.TAction) {
const path = action.payload.location.pathname;

// reset on each opds navigation, already set up previously but only when accessing the opds flow not on the catalog list.
// Reset useful here when accessing an authenticated flow without concretely authenticating this flow (transitive state).
// Header links are no longer updated by accumulation based on the links browsed but by set and replace each time an opds page is discovered (stateless).
if (path.startsWith("/opds")) {
// reset
yield put(opdsActions.headerLinksUpdate.build({
}));
yield put(opdsActions.search.build({
}));
}

if (path.startsWith("/opds") && path.indexOf("/browse") > 0) {
const parsedResult = parseOpdsBrowserRoute(path);
debug("request opds browse", path, parsedResult);
Expand All @@ -52,12 +63,6 @@ function* browseWatcher(action: routerActions.locationChanged.TAction) {
const newParsedResultTitle = tryDecodeURIComponent(parsedResult.title);
debug(newParsedResultTitle);

// reset
yield put(opdsActions.search.build({
}));
yield put(opdsActions.headerLinksUpdate.build({
}));

// re-render opds navigator
yield put(
opdsActions.browseRequest.build(
Expand Down

0 comments on commit 51914df

Please sign in to comment.