message: Fixes Generalized the confirmation modals in the privacy controls
diff: @@ -29,24 +29,15 @@ class PrivacyControl extends preact.Component {
  /* TODO: I think we need some kind of 'feedback' here to confirm to the user that the setting has indeed been saved. */
  Privacy.setAllowed(PRIVACY_ACTIONS[this.props.privacy_action], this.state.enabled);
  - if(this.props.privacy_action === 'SAVE_MY_REQUESTS' && this.state.enabled === false) {
  - this.props.showModal(
  - <Modal positiveText={t('confirm-clear-requests', 'privacy-controls')} negativeText={t('cancel', 'privacy-controls')}
  - onNegativeFeedback={this.props.hideModal} onPositiveFeedback={e => {
  - this.props.hideModal();
  - PrivacyControls.clearRequests();
  - }} positiveDefault={true} onDismiss={this.props.hideModal}>
  - <Text id='confirm-delete-my-requests' />
  - </Modal>);
  - } else if(this.props.privacy_action === 'SAVE_ID_DATA' && this.state.enabled === false) {
  - this.props.showModal(
  - <Modal positiveText={t('clear-id_data', 'privacy-controls')} negativeText={t('cancel', 'privacy-controls')}
  - onNegativeFeedback={this.props.hideModal} onPositiveFeedback={e => {
  - this.props.hideModal();
  - PrivacyControls.clearIdData();
  - }} positiveDefault={true} onDismiss={this.props.hideModal}>
  - <Text id='confirm-delete-id_data' />
  - </Modal>);
  + if(this.state.enabled === false) {
  + switch(this.props.privacy_action) {
  + case 'SAVE_ID_DATA':
  + this.clearModal('clear-id_data', 'confirm-delete-id_data', PrivacyControls.clearIdData);
  + break;
  + case 'SAVE_MY_REQUESTS':
  + this.clearModal('confirm-clear-requests', 'confirm-delete-my-requests', PrivacyControls.clearRequests);
  + break;
  + }
  }
  }
  @@ -59,6 +50,17 @@ class PrivacyControl extends preact.Component {
  </trow>
  </div>;
  }
  +
  + clearModal(button_text_id, body_text_id, clear_function) {
  + this.props.showModal(
  + <Modal positiveText={t(button_text_id, 'privacy-controls')} negativeText={t('cancel', 'privacy-controls')}
  + onNegativeFeedback={this.props.hideModal} onPositiveFeedback={e => {
  + this.props.hideModal();
  + clear_function();
  + }} positiveDefault={true} onDismiss={this.props.hideModal}>
  + <Text id={body_text_id} />
  + </Modal>);
  + }
  }
  class PrivacyControls extends preact.Component {
  