From d3be6357eff7cdb97534f1d75cc6dc625a84e18f Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 12 Sep 2019 08:19:45 -0700 Subject: [PATCH] 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 --- src/chrome/RatingButton.tsx | 10 ++++++++-- src/fb-stubs/UserFeedback.tsx | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/chrome/RatingButton.tsx b/src/chrome/RatingButton.tsx index d9210febf..4811f2bde 100644 --- a/src/chrome/RatingButton.tsx +++ b/src/chrome/RatingButton.tsx @@ -20,6 +20,8 @@ import GK from '../fb-stubs/GK'; import * as UserFeedback from '../fb-stubs/UserFeedback'; import {FeedbackPrompt} from '../fb-stubs/UserFeedback'; +const useEligibilityCheck = GK.get('flipper_use_itsr_eligibility_check'); + type Props = { onRatingChanged: (rating: number) => void; }; @@ -254,7 +256,7 @@ export default class RatingButton extends Component { state = { promptData: null, isShown: false, - userIsEligible: !GK.get('flipper_use_itsr_eligibility_check'), + userIsEligible: !useEligibilityCheck, }; constructor(props: Props) { @@ -265,7 +267,11 @@ export default class RatingButton extends Component { } onClick() { - this.setState({isShown: !this.state.isShown}); + const willBeShown = !this.state.isShown; + this.setState({isShown: willBeShown}); + if (!willBeShown && useEligibilityCheck) { + UserFeedback.dismiss(); + } } submitRating(rating: number) { diff --git a/src/fb-stubs/UserFeedback.tsx b/src/fb-stubs/UserFeedback.tsx index ee254810b..1d3a1e07f 100644 --- a/src/fb-stubs/UserFeedback.tsx +++ b/src/fb-stubs/UserFeedback.tsx @@ -27,6 +27,9 @@ export async function submitComment( ): Promise { throw new Error('Method not implemented.'); } +export async function dismiss(): Promise { + throw new Error('Method not implemented.'); +} export async function getPrompt(): Promise { throw new Error('Method not implemented.'); }