FIX: Subsequent results in full page search should re-trigger discovery (#1156)
This update fixes an issue where subsequent results in full page search were not trigger Discobot discoveries to search for the new result.
This commit is contained in:
parent
e15952031d
commit
a3fb5cdc21
|
|
@ -21,6 +21,7 @@ export default class AiSearchDiscoveries extends Component {
|
|||
@service search;
|
||||
@service messageBus;
|
||||
@service discobotDiscoveries;
|
||||
@service appEvents;
|
||||
|
||||
@tracked loadingDiscoveries = false;
|
||||
@tracked hideDiscoveries = false;
|
||||
|
|
@ -34,6 +35,24 @@ export default class AiSearchDiscoveries extends Component {
|
|||
typingTimer = null;
|
||||
streamedTextLength = 0;
|
||||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.appEvents.on(
|
||||
"full-page-search:trigger-search",
|
||||
this,
|
||||
this.triggerDiscovery
|
||||
);
|
||||
}
|
||||
|
||||
willDestroy() {
|
||||
super.willDestroy(...arguments);
|
||||
this.appEvents.off(
|
||||
"full-page-search:trigger-search",
|
||||
this,
|
||||
this.triggerDiscovery
|
||||
);
|
||||
}
|
||||
|
||||
typeCharacter() {
|
||||
if (this.streamedTextLength < this.discobotDiscoveries.discovery.length) {
|
||||
this.streamedText += this.discobotDiscoveries.discovery.charAt(
|
||||
|
|
@ -48,11 +67,20 @@ export default class AiSearchDiscoveries extends Component {
|
|||
}
|
||||
|
||||
onTextUpdate() {
|
||||
this.cancelTypingTimer();
|
||||
this.typeCharacter();
|
||||
}
|
||||
|
||||
cancelTypingTimer() {
|
||||
if (this.typingTimer) {
|
||||
cancel(this.typingTimer);
|
||||
}
|
||||
}
|
||||
|
||||
this.typeCharacter();
|
||||
resetStreaming() {
|
||||
this.cancelTypingTimer();
|
||||
this.streamedText = "";
|
||||
this.streamedTextLength = 0;
|
||||
}
|
||||
|
||||
@bind
|
||||
|
|
@ -77,10 +105,7 @@ export default class AiSearchDiscoveries extends Component {
|
|||
this.isStreaming = false;
|
||||
|
||||
// Clear pending animations
|
||||
if (this.typingTimer) {
|
||||
cancel(this.typingTimer);
|
||||
this.typingTimer = null;
|
||||
}
|
||||
this.cancelTypingTimer();
|
||||
} else if (newText.length > this.discobotDiscoveries.discovery.length) {
|
||||
this.discobotDiscoveries.discovery = newText;
|
||||
this.isStreaming = true;
|
||||
|
|
@ -148,6 +173,7 @@ export default class AiSearchDiscoveries extends Component {
|
|||
this.hideDiscoveries = false;
|
||||
return;
|
||||
} else {
|
||||
this.resetStreaming();
|
||||
this.discobotDiscoveries.resetDiscovery();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue