Skip to content

Commit

Permalink
fix(headless): fix answer state using the new pattern (#4271)
Browse files Browse the repository at this point in the history
[SVCC-4040](https://coveord.atlassian.net/browse/SVCC-4040)

**Problems:**

1. states of the answer aren't reset after a new request: when you click
on like/dislike/expand for example, the new query doesn't reset the
state, we still can see the button liked or disliked clicked for example
from the previous query.
2. When you submit a feedback, and re-click on likes/disliked, the
feedback modal still shows even if the feedback was successfully
submitted.

**Solutions:**

1. Reset the state when we perform a new query.
2. update `feedbackSumbitted` state when calling `sendFeedback` in the
new pattern.

**DEMO:**


https://github.com/user-attachments/assets/3377b367-5985-4045-8ad6-e072f81c9645



[SVCC-4040]:
https://coveord.atlassian.net/browse/SVCC-4040?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
jelmedini authored Aug 13, 2024
1 parent b94476d commit d1bcc53
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import {SearchEngine} from '../../../app/search-engine/search-engine';
import {
resetAnswer,
sendGeneratedAnswerFeedback,
updateAnswerConfigurationId,
} from '../../../features/generated-answer/generated-answer-actions';
import {GeneratedAnswerFeedbackV2} from '../../../features/generated-answer/generated-answer-analytics-actions';
Expand Down Expand Up @@ -102,6 +103,7 @@ const subscribeToSearchRequest = (
return;
}
lastTriggerParams = triggerParams;
engine.dispatch(resetAnswer());
engine.dispatch(fetchAnswer(state));
};
engine.subscribe(strictListener);
Expand Down Expand Up @@ -172,6 +174,7 @@ export function buildAnswerApiGeneratedAnswer(
answerApiState: selectAnswer(engine.state).data!,
});
engine.dispatch(answerEvaluation.endpoints.post.initiate(args));
engine.dispatch(sendGeneratedAnswerFeedback());
},
};
}
Expand Down

0 comments on commit d1bcc53

Please sign in to comment.