Skip to content

Commit

Permalink
Fix redo functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
RodriSanchez1 committed Dec 22, 2023
1 parent c1f172a commit 3d9bda2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/components/Board/Output/Output.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,22 @@ export class OutputContainer extends Component {
handleRepeatLastSpokenSentence = event => {
const Z_KEY_CODE = 90;
const Y_KEY_CODE = 89;
const { output } = this.props;
if (
(event.ctrlKey && event.shiftKey && event.keyCode === Z_KEY_CODE) ||
(event.ctrlKey && event.keyCode === Y_KEY_CODE)
((event.ctrlKey && event.shiftKey && event.keyCode === Z_KEY_CODE) ||
(event.ctrlKey && event.keyCode === Y_KEY_CODE)) &&
!!output.length
) {
const { output } = this.props;
const lastSpokenSymbol = output.findLast(
(element, index) => element.label && index !== output.length - 1
const isLastSpokenSymbol = (element, index) => {
if (output.length === 1) return true;
if (element.label) {
return element.type === 'live' ? index < output.length - 1 : true;
}
return false;
};

const lastSpokenSymbol = output.findLast((element, index) =>
isLastSpokenSymbol(element, index)
);
const text = lastSpokenSymbol ? lastSpokenSymbol.label : '';
this.speakOutput(text);
Expand Down

0 comments on commit 3d9bda2

Please sign in to comment.