<commit_before>import { c } from 'ttag';

import useFeature from '../../hooks/useFeature';
import { FeatureCode } from '../features/FeaturesContext';
import FeedbackModal, { FeedbackModalProps } from './FeedbackModal';
import { RebrandingFeatureValue } from './useRebrandingFeedback';

interface RebrandingModalProps extends Partial<FeedbackModalProps> {
    onMount?: () => void;
}

const RebrandingFeedbackModal = (props: RebrandingModalProps) => {
    const rebranding = useFeature<RebrandingFeatureValue>(FeatureCode.RebrandingFeedback);

    const handleSuccess = () => {
        /*
         * The value of the rebranding feature is guaranteed to exist here
         * because we're disabling the Feedback Modal until it's available.
         */
        rebranding.update({
            ...rebranding.feature!.Value,
            hasGivenRebrandingFeedback: true,
        });
    };

    if (!rebranding.feature?.Value) {
        return null;
    }

    return (
        <FeedbackModal
            size="medium"
            onSuccess={handleSuccess}
            feedbackType="web_clients_relaunch"
            scaleTitle={c('Label').t`How would you describe your experience with the new Proton?`}
            scaleProps={{
                fromLabel: c('Label').t`Awful`,
                toLabel: c('Label').t`Wonderful`,
            }}
            {...props}
        />
    );
};

export default RebrandingFeedbackModal;
<commit_msg>Only update hasGivenRebrandingFeedback if it's not already set to true<commit_after>import { c } from 'ttag';

import useFeature from '../../hooks/useFeature';
import { FeatureCode } from '../features/FeaturesContext';
import FeedbackModal, { FeedbackModalProps } from './FeedbackModal';
import { RebrandingFeatureValue } from './useRebrandingFeedback';

interface RebrandingModalProps extends Partial<FeedbackModalProps> {
    onMount?: () => void;
}

const RebrandingFeedbackModal = (props: RebrandingModalProps) => {
    const rebranding = useFeature<RebrandingFeatureValue>(FeatureCode.RebrandingFeedback);

    const handleSuccess = () => {
        if (rebranding.feature?.Value.hasGivenRebrandingFeedback !== true) {
            /*
             * The value of the rebranding feature is guaranteed to exist here
             * because we're disabling the Feedback Modal until it's available.
             */
            rebranding.update({
                ...rebranding.feature!.Value,
                hasGivenRebrandingFeedback: true,
            });
        }
    };

    if (!rebranding.feature?.Value) {
        return null;
    }

    return (
        <FeedbackModal
            size="medium"
            onSuccess={handleSuccess}
            feedbackType="web_clients_relaunch"
            scaleTitle={c('Label').t`How would you describe your experience with the new Proton?`}
            scaleProps={{
                fromLabel: c('Label').t`Awful`,
                toLabel: c('Label').t`Wonderful`,
            }}
            {...props}
        />
    );
};

export default RebrandingFeedbackModal;

{'fraction_non_alphanumeric': 0.11220472440944881, 'fraction_numerical': 0.0, 'mean_word_length': 2.4451977401129943, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1565402', 'n_tokens_mistral': 844, 'n_tokens_neox': 816, 'n_words': 188}