Send dismiss event when popover is closed

Summary: Dismissing the popover will stiop the user from being prompted for a while, so we only want to send this event when the user was proactively prompted in the first place - which is when we're using the eligibility check.

Reviewed By: passy

Differential Revision: D17343227

fbshipit-source-id: 95a071e34ce318fe49640c6ee9f68127957f390c
This commit is contained in:
John Knox
2019-09-12 08:19:45 -07:00
committed by Facebook Github Bot
parent 25739aebc2
commit d3be6357ef
2 changed files with 11 additions and 2 deletions

View File

@@ -20,6 +20,8 @@ import GK from '../fb-stubs/GK';
import * as UserFeedback from '../fb-stubs/UserFeedback'; import * as UserFeedback from '../fb-stubs/UserFeedback';
import {FeedbackPrompt} from '../fb-stubs/UserFeedback'; import {FeedbackPrompt} from '../fb-stubs/UserFeedback';
const useEligibilityCheck = GK.get('flipper_use_itsr_eligibility_check');
type Props = { type Props = {
onRatingChanged: (rating: number) => void; onRatingChanged: (rating: number) => void;
}; };
@@ -254,7 +256,7 @@ export default class RatingButton extends Component<Props, State> {
state = { state = {
promptData: null, promptData: null,
isShown: false, isShown: false,
userIsEligible: !GK.get('flipper_use_itsr_eligibility_check'), userIsEligible: !useEligibilityCheck,
}; };
constructor(props: Props) { constructor(props: Props) {
@@ -265,7 +267,11 @@ export default class RatingButton extends Component<Props, State> {
} }
onClick() { onClick() {
this.setState({isShown: !this.state.isShown}); const willBeShown = !this.state.isShown;
this.setState({isShown: willBeShown});
if (!willBeShown && useEligibilityCheck) {
UserFeedback.dismiss();
}
} }
submitRating(rating: number) { submitRating(rating: number) {

View File

@@ -27,6 +27,9 @@ export async function submitComment(
): Promise<void> { ): Promise<void> {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }
export async function dismiss(): Promise<void> {
throw new Error('Method not implemented.');
}
export async function getPrompt(): Promise<FeedbackPrompt> { export async function getPrompt(): Promise<FeedbackPrompt> {
throw new Error('Method not implemented.'); throw new Error('Method not implemented.');
} }