Skip to content

Commit

Permalink
fix: LCP passphrase dialog wasa acompanied by confusing red toast not…
Browse files Browse the repository at this point in the history
…ification to announce load failure (Fixes #1084 PR #1089)
  • Loading branch information
panaC authored Jun 9, 2020
1 parent 82fc65f commit 233283e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/main/redux/sagas/publication/openPublication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { Publication as R2Publication } from "@r2-shared-js/models/publication";
const filename_ = "readium-desktop:main:redux:sagas:publication:open";
const debug = debug_(filename_);

export const ERROR_MESSAGE_ON_USERKEYCHECKREQUEST = "ERROR_MESSAGE_ON_USERKEYCHECKREQUEST";

export function* streamerOpenPublicationAndReturnManifestUrl(pubId: string) {

const publicationRepository = yield* callTyped(
Expand Down Expand Up @@ -106,7 +108,7 @@ export function* streamerOpenPublicationAndReturnManifestUrl(pubId: string) {
message,
));

throw new Error(message);
throw ERROR_MESSAGE_ON_USERKEYCHECKREQUEST;
} catch (error) {

throw error;
Expand Down Expand Up @@ -187,7 +189,7 @@ export function* streamerOpenPublicationAndReturnManifestUrl(pubId: string) {
message,
));

throw new Error(message);
throw ERROR_MESSAGE_ON_USERKEYCHECKREQUEST;
} catch (error) {

throw error;
Expand Down
30 changes: 18 additions & 12 deletions src/main/redux/sagas/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import { ObjectValues } from "readium-desktop/utils/object-keys-values";
import { all, call, put, take } from "redux-saga/effects";
import { types } from "util";

import { streamerOpenPublicationAndReturnManifestUrl } from "./publication/openPublication";
import {
ERROR_MESSAGE_ON_USERKEYCHECKREQUEST, streamerOpenPublicationAndReturnManifestUrl,
} from "./publication/openPublication";

// Logger
const filename_ = "readium-desktop:main:saga:reader";
Expand Down Expand Up @@ -255,20 +257,24 @@ function* readerOpenRequest(action: readerActions.openRequest.TAction) {

} catch (e) {

const translator = yield* callTyped(
() => diMainGet("translator"));
if (e.toString() !== ERROR_MESSAGE_ON_USERKEYCHECKREQUEST) {

const translator = yield* callTyped(
() => diMainGet("translator"));

if (types.isNativeError(e)) {
// disable "Error: "
e.name = "";
}

if (types.isNativeError(e)) {
// disable "Error: "
e.name = "";
yield put(
toastActions.openRequest.build(
ToastType.Error,
translator.translate("message.open.error", { err: e.toString() }),
),
);
}

yield put(
toastActions.openRequest.build(
ToastType.Error,
translator.translate("message.open.error", {err: e.toString()}),
),
);
}

if (manifestUrl) {
Expand Down

0 comments on commit 233283e

Please sign in to comment.