<commit_before>import { default as React, Component } from 'react';
import { storageService } from '../service/StorageService';
import { render } from 'react-dom';
import { Modal } from 'react-bootstrap';
import { authOperation, authEmitter } from '../service/authOperation';

export class SubscribeModal extends Component {
	constructor(props) {
		super(props);
		this.state = {
			showModal: false,
			profile: false,
			subscribeOption: 'major'
		};
		this.options = {
			option1: {
				value: 'major',
				text: 'New GEM releases'
			},
			option2: {
				value: 'all',
				text: 'Limited major updates'
			}
		}
		this.timer = 1;
		this.activetab = true;
		this.holdSubscribe = false;
		this.init();
	}
	init() {
		authEmitter.addListener('profile', (data) => {
			this.setState({
				profile: data
			});
		});
		if (storageService.get('popuptimer')) {
			this.timer = parseInt(storageService.get('popuptimer'));
		}
		setTimeout(() => {
			if (!this.state.profile) {
				this.open();
			}
		}, 1000 * 60 * this.timer);

		$(window).focus(function() {
			this.activetab = true;
			setTimeout(() => {
				if (!this.state.profile && this.holdSubscribe) {
					this.open();
				}
			}, 1000 * 10 * this.timer);
		}.bind(this));

		$(window).blur(function() {
			this.activetab = false;
		}.bind(this));
	}
	close() {
		this.internalClose = true;
		storageService.set('popuptimer', this.timer + 5);
		this.setState({ showModal: false });
	}
	open() {
		if (!this.state.profile) {
			if (!$('.fade.in.modal').length) {
				if(this.activetab) {
					this.setState({ showModal: true });
				} else {
					this.holdSubscribe = true;
				}
			} else {
				setTimeout(() => {
					this.open();
				}, 1000 * 10);
			}
		}
	}
	subscribe() {
		authOperation.login(this.state.subscribeOption);
	}
	subscribeOptionChange(value) {
		this.setState({
			subscribeOption: value
		});
	}
	showIcon() {
		let icon = (<i className="fa fa-envelope-o"></i>);
		if (this.state.profile) {
			icon = (<i className="fa fa-check"></i>);
		}
		return icon;
	}
	render() {
		return (
		<div>
			<a title="Subscribe to updates" className="subscribe" href="javascript:void;" onClick={() => this.open()}>
				{this.showIcon()}
			</a>
			<Modal className="modal-info" show={this.state.showModal} onHide={() => this.close()}>
			<Modal.Header closeButton>
				<Modal.Title>Be in the know about major updates!</Modal.Title>
			</Modal.Header>
			<Modal.Body>
				<div className="row">
					<div className="col-xs-12">
						<div className="row">
							<div className="col-xs-12 single-option">
								<label className="radio-inline">
								<input type="radio"
									checked={this.state.subscribeOption === this.options.option1.value}
									onChange={() => this.subscribeOptionChange(this.options.option1.value)}
									name="subscribeOption" id="subscribeOption" value={this.options.option1.value} /> {this.options.option1.text}
								</label>
							</div>
							<div className="col-xs-12 single-option">
								<label className="radio-inline">
								<input type="radio"
									checked={this.state.subscribeOption === this.options.option2.value}
									onChange={() => this.subscribeOptionChange(this.options.option2.value)}
									name="subscribeOption1" id="subscribeOption1" value={this.options.option2.value} /> {this.options.option2.text}
								</label>
							</div>
						</div>
					</div>
				</div>
				<div className="col-xs-12 text-center">
					<button className="btn btn-primary" onClick={() => this.subscribe()}>
						<i className="fa fa-github"></i> Subscribe with Github
					</button>
				</div>
				</Modal.Body>
			</Modal>
		</div>
		)
	}
}
me="fa fa-github"></i> Subscribe with Github
              </button>
            </div>
          </Modal.Body>
        </Modal>
      </div>
    )
  }
}
<commit_msg>Fix subscribe modal<commit_after>import { default as React, Component } from 'react';
import { storageService } from '../service/StorageService';
import { render } from 'react-dom';
import { Modal } from 'react-bootstrap';
import { authOperation, authEmitter } from '../service/authOperation';

export class SubscribeModal extends Component {
	constructor(props) {
		super(props);
		this.state = {
			showModal: false,
			profile: false,
			subscribeOption: 'major'
		};
		this.options = {
			option1: {
				value: 'major',
				text: 'New GEM releases'
			},
			option2: {
				value: 'all',
				text: 'Limited major updates'
			}
		}
		this.timer = 1;
		this.activetab = true;
		this.holdSubscribe = false;
		this.init();
	}
	init() {
		authEmitter.addListener('profile', (data) => {
			this.setState({
				profile: data
			});
		});
		if (storageService.get('popuptimer')) {
			this.timer = parseInt(storageService.get('popuptimer'));
		}
		setTimeout(() => {
			if (!this.state.profile) {
				this.open();
			}
		}, 1000 * 60 * this.timer);

		$(window).focus(function() {
			this.activetab = true;
			setTimeout(() => {
				if (!this.state.profile && this.holdSubscribe) {
					this.open();
				}
			}, 1000 * 10 * this.timer);
		}.bind(this));

		$(window).blur(function() {
			this.activetab = false;
		}.bind(this));
	}
	close() {
		this.internalClose = true;
		storageService.set('popuptimer', this.timer + 5);
		this.setState({ showModal: false });
	}
	open() {
		if (!this.state.profile) {
			if (!$('.fade.in.modal').length) {
				if(this.activetab) {
					this.setState({ showModal: true });
				} else {
					this.holdSubscribe = true;
				}
			} else {
				setTimeout(() => {
					this.open();
				}, 1000 * 10);
			}
		}
	}
	subscribe() {
		authOperation.login(this.state.subscribeOption);
	}
	subscribeOptionChange(value) {
		this.setState({
			subscribeOption: value
		});
	}
	showIcon() {
		let icon = (<i className="fa fa-envelope-o"></i>);
		if (this.state.profile) {
			icon = (<i className="fa fa-check"></i>);
		}
		return icon;
	}
	render() {
		return (
		<div>
			<a title="Subscribe to updates" className="subscribe" href="javascript:void;" onClick={() => this.open()}>
				{this.showIcon()}
			</a>
			<Modal className="modal-info" show={this.state.showModal} onHide={() => this.close()}>
			<Modal.Header closeButton>
				<Modal.Title>Be in the know about major updates!</Modal.Title>
			</Modal.Header>
			<Modal.Body>
				<div className="row">
					<div className="col-xs-12">
						<div className="row">
							<div className="col-xs-12 single-option">
								<label className="radio-inline">
								<input type="radio"
									checked={this.state.subscribeOption === this.options.option1.value}
									onChange={() => this.subscribeOptionChange(this.options.option1.value)}
									name="subscribeOption" id="subscribeOption" value={this.options.option1.value} /> {this.options.option1.text}
								</label>
							</div>
							<div className="col-xs-12 single-option">
								<label className="radio-inline">
								<input type="radio"
									checked={this.state.subscribeOption === this.options.option2.value}
									onChange={() => this.subscribeOptionChange(this.options.option2.value)}
									name="subscribeOption1" id="subscribeOption1" value={this.options.option2.value} /> {this.options.option2.text}
								</label>
							</div>
						</div>
					</div>
				</div>
				<div className="col-xs-12 text-center">
					<button className="btn btn-primary" onClick={() => this.subscribe()}>
						<i className="fa fa-github"></i> Subscribe with Github
					</button>
				</div>
				</Modal.Body>
			</Modal>
		</div>
		)
	}
}

{'fraction_non_alphanumeric': 0.17817164179104478, 'fraction_numerical': 0.010660980810234541, 'mean_word_length': 2.95, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 104, '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': '5081387', 'n_tokens_mistral': 3124, 'n_tokens_neox': 2458, 'n_words': 472}