Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/BloomBrowserUI/bookEdit/TextBoxProperties/TextBoxProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,18 @@ export default class TextBoxProperties {
}
fillInLanguageNames() {
get("editView/getBookLangs", (result) => {
document.getElementById("tbprop-lang1")!.innerText =
"(" + result.data.V + ")";
document.getElementById("tbprop-lang2")!.innerText =
"(" + result.data.N1 + ")";
document.getElementById("tbprop-lang3")!.innerText =
"(" + result.data.N2 + ")";
// This is an async callback: by the time getBookLangs returns, the dialog may
// already have been closed and these elements removed from the DOM. In that case
// getElementById returns null; bail rather than throw (Sentry BLOOM-DESKTOP-FFJ).
// Guard all three (not just the first): don't rely on an assumption about the
// order in which the dialog's elements are torn down.
const lang1 = document.getElementById("tbprop-lang1");
const lang2 = document.getElementById("tbprop-lang2");
const lang3 = document.getElementById("tbprop-lang3");
if (!lang1 || !lang2 || !lang3) return;
lang1.innerText = "(" + result.data.V + ")";
lang2.innerText = "(" + result.data.N1 + ")";
lang3.innerText = "(" + result.data.N2 + ")";
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ export class LeveledReaderTool extends ToolboxToolReactAdaptor {
public beginRestoreSettings(opts: string): JQueryPromise<void> {
return beginInitializeLeveledReaderTool().then(() => {
const restoreDone = $.Deferred<void>();
// opts can be undefined/null when the tool is activated for a book that has no
// saved leveled-reader settings. Guard before indexing so we fall through to the
// default-level path instead of throwing an unhandled promise rejection that
// aborts tool activation (Sentry BLOOM-DESKTOP-FFH).
const leveledReaderState = (
opts as unknown as Record<string, string>
)["leveledReaderState"];
opts as unknown as Record<string, string> | undefined
)?.["leveledReaderState"];
if (leveledReaderState) {
// The true passed here prevents re-saving the state we just read.
// One non-obvious implication is that simply opening a level-4 book
Expand Down