-
-
Notifications
You must be signed in to change notification settings - Fork 19
Converted Talking Book Tool to React (BL-16410) #8075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
josiahwall
wants to merge
5
commits into
master
Choose a base branch
from
talkingBookToolReact
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
58fd161
Add plan document for converting Talking Book tool to React
JohnThomson eb8388c
Merge branch 'master' into talkingBookToolReact
josiahwall ea4e001
Update plan following a Fable review
JohnThomson 9053f0d
Merge branch 'talkingBookToolReact' of https://github.com/BloomBooks/…
josiahwall 5191780
Converted Talking Book Tool to React (BL-16410)
josiahwall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // taken out of audioRecording.ts to avoid the need for other | ||
| // files to import that big file just to use a little bit of | ||
| // code. | ||
|
|
||
| import axios, { AxiosResponse } from "axios"; | ||
|
|
||
| export const kAnyRecordingApiUrl = "/bloom/api/audio/checkForAnyRecording?ids="; | ||
|
|
||
| export async function audioExistsForIdsAsync(ids: string[]): Promise<boolean> { | ||
| try { | ||
| const response: AxiosResponse<any> = await axios.get( | ||
| `${kAnyRecordingApiUrl}${ids}`, | ||
| ); | ||
| return doesNarrationExist(response); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| // Given a response from kAnyRecordingApiUrl, determines whether narration audio exists | ||
| // for any of the specified IDs. | ||
| export function doesNarrationExist(response: AxiosResponse<any>): boolean { | ||
| return response && response.data === true; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // taken out of audioRecording.ts to avoid the need for other | ||
| // files to import that big file just to use a little bit of | ||
| // code. | ||
|
|
||
| import { getMd5 } from "../toolbox/talkingBook/md5Util"; | ||
|
|
||
| export function getChecksum(message: string): string { | ||
| if (message === null || message === undefined) { | ||
| // should not normally happen, but seems to in tests. | ||
| // The function is supposed to return a string, and I don't want to change | ||
| // all the callers, so making it return a string that's a bit unique so if | ||
| // we ever see it in production we can search for it. | ||
| return "undefind"; | ||
| } | ||
| // Vertical line character ("|") acts as a phrase delimiter in Talking Books. | ||
| // To perform phrase-level recording, the user can insert a temporary "|" character where he wants a phrase split to happen. | ||
| // This is now recognized in the list of sentence delimiters, so it will be broken up as an audio-sentence. | ||
| // Then the user records the audio. | ||
| // Then the user deletes the vertical line characters. | ||
| // Now the text should be the desired final state, and audio recordings are possible at a sub-sentence level. | ||
| // However, we don't want the sentence markup to be updated because the checksums differ (since a character was deleted). | ||
| // | ||
| // Thus, our checksum function needs to ignore the vertical line character when computing the checksum. | ||
| const adjustedMessage = message.replace("|", ""); | ||
| return getMd5(adjustedMessage); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // taken out of audioRecording.ts to avoid the need for other | ||
| // files to import that big file just to use a little bit of | ||
| // code. | ||
|
|
||
| export const kPlaybackOrderContainerClass: string = | ||
| "bloom-playbackOrderControlsContainer"; | ||
|
|
||
| export const kAudioCurrent = "ui-audioCurrent"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // taken out of audioRecording.ts to avoid the need for other | ||
| // files to import that big file just to use a little bit of | ||
| // code. | ||
|
|
||
| import { EditableDivUtils } from "./editableDivUtils"; | ||
|
|
||
| export function createValidXhtmlUniqueId(): string { | ||
| let newId = EditableDivUtils.createUuid(); | ||
| if (/^\d/.test(newId)) { | ||
| newId = "i" + newId; // valid ID in XHTML can't start with digit | ||
| } | ||
|
|
||
| return newId; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|is stripped.String.prototype.replacewith a plain string argument stops after the first match, so a sentence like"Hello | World | test"produces checksum"Hello World | test"— the second pipe is retained. After the user deletes all delimiter characters the actual text becomes"Hello World test", so the checksums never agree and the audio markup is unnecessarily regenerated every session. Use a global regex to remove all occurrences.