diff --git a/src/chrome/RatingButton.tsx b/src/chrome/RatingButton.tsx index 7df98fe5c..4f1905da2 100644 --- a/src/chrome/RatingButton.tsx +++ b/src/chrome/RatingButton.tsx @@ -20,8 +20,6 @@ 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; }; @@ -29,7 +27,6 @@ type Props = { type State = { promptData: FeedbackPrompt | null; isShown: boolean; - userIsEligible: boolean; hasTriggered: boolean; }; @@ -254,24 +251,26 @@ class FeedbackComponent extends Component< } export default class RatingButton extends Component { - state = { + state: State = { promptData: null, isShown: false, - userIsEligible: !useEligibilityCheck, hasTriggered: false, }; constructor(props: Props) { super(props); - UserFeedback.getPrompt().then(prompt => - this.setState({promptData: prompt}), - ); + if (GK.get('flipper_rating')) { + UserFeedback.getPrompt().then(prompt => { + this.setState({promptData: prompt}); + setTimeout(this.triggerPopover.bind(this), 30000); + }); + } } onClick() { const willBeShown = !this.state.isShown; this.setState({isShown: willBeShown, hasTriggered: true}); - if (!willBeShown && useEligibilityCheck) { + if (!willBeShown) { UserFeedback.dismiss(); } } @@ -300,28 +299,17 @@ export default class RatingButton extends Component { } } - setIsEligible(isEligible: boolean) { - this.setState({userIsEligible: isEligible}); - if (isEligible) { - setTimeout(this.triggerPopover.bind(this), 30000); - } - } - render() { - if (!GK.get('flipper_rating')) { - return null; - } - if (!this.state.userIsEligible) { - return ( - - ); - } const promptData = this.state.promptData; if (!promptData) { return null; } + if ( + !promptData.shouldPopup || + (this.state.hasTriggered && !this.state.isShown) + ) { + return null; + } return (
diff --git a/src/fb-stubs/UserFeedback.tsx b/src/fb-stubs/UserFeedback.tsx index 1d3a1e07f..0e5b20bcc 100644 --- a/src/fb-stubs/UserFeedback.tsx +++ b/src/fb-stubs/UserFeedback.tsx @@ -33,6 +33,3 @@ export async function dismiss(): Promise { export async function getPrompt(): Promise { throw new Error('Method not implemented.'); } -export class StarRatingsEligibilityChecker extends Component<{ - callback: (userIsEligible: boolean) => void; -}> {}