Skip to content
This repository was archived by the owner on Jan 4, 2021. It is now read-only.

Commit b0f21c2

Browse files
author
Francois-Xavier Gentilhomme
committed
[FIX] fixes issue on text result mgmt
1 parent 111fc6a commit b0f21c2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

myscript-text-web.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,18 @@
145145
*/
146146
function textManageResultEvent(myscriptTextWebElement, eventDetail) {
147147
myscriptTextWebElement.result = {};
148-
if (eventDetail.rawResult && eventDetail.rawResult.result) {
149-
textUpdateCandidatesCustomLabel(eventDetail.rawResult.result);
148+
myscriptTextWebElement.resultlabel = '';
149+
myscriptTextWebElement.candidates = [];
150+
if (eventDetail.rawResult &&
151+
eventDetail.rawResult.result &&
152+
eventDetail.rawResult.result.textSegmentResult &&
153+
eventDetail.rawResult.result.textSegmentResult.candidates) {
154+
150155
myscriptTextWebElement.result = eventDetail.rawResult.result;
151156
myscriptTextWebElement.resultlabel = eventDetail.rawResult.result.textSegmentResult.candidates[eventDetail.rawResult.result.textSegmentResult.selectedCandidateIdx].label;
152157
myscriptTextWebElement.candidates = eventDetail.rawResult.result.textSegmentResult.candidates;
153158
myscriptTextWebElement.candidates[eventDetail.rawResult.result.textSegmentResult.selectedCandidateIdx].selected = true; // FIXME: ugly hack to mark selected candidate
159+
textUpdateCandidatesCustomLabel(myscriptTextWebElement);
154160
}
155161
}
156162

@@ -165,7 +171,8 @@
165171
/**
166172
* Update custom label of candidates by theirs owns properties
167173
*/
168-
function textUpdateCandidatesCustomLabel(result) {
174+
function textUpdateCandidatesCustomLabel(myscriptTextWebElement) {
175+
var result = myscriptTextWebElement.result;
169176
result.textSegmentResult.candidates.forEach(function (candidate) {
170177
var textLabel = '<span class="text myscript-text-web">';
171178
if (candidate.flags && candidate.flags.indexOf('PREDICTED') > -1) {

0 commit comments

Comments
 (0)