<commit_before>
'use strict';

import React, {
    AppRegistry,
    Component,
    StyleSheet,
    Text,
    Image,
    View,
    TouchableHighlight,
    TouchableNativeFeedback,
    Platform,
} from 'react-native';

import SimpleStore from 'react-native-simple-store';

import AnswerScreen from './answer-screen';
import CommonStyles from './common-styles.js';
import TweetBox from './tweet-box.js';
import Toolbar from './toolbar.js';
import API from './api.js';
import Constants from './constants.js';

var TouchableElement = TouchableHighlight;
if (Platform.OS === 'android') {
    TouchableElement = TouchableNativeFeedback;
}

class QuestionScreen extends Component {
    constructor(props) {
        super(props);
        this.state = { question: null, currentStreak: null };
    }

    componentWillMount() {
        SimpleStore.get('questions').then((questions) => {
            var question = this.pickRandomQuestion(questions);
            question.options = this.shuffleArray(question.options);
            this.setState(Object.assign(this.state, { question: question }));
        });

        SimpleStore.get('currentStreak').then((currentStreak) => {
            SimpleStore.get('bestStreak').then((bestStreak) => {
                bestStreak = bestStreak || 0;
                this.setState(Object.assign(this.state, {
                    currentStreak: currentStreak,
                    bestStreak: bestStreak,
                }));
            });
        });
    }

    render() {
        if (!this.state.question) {
            return (
                <View style={[CommonStyles.screenBackground, styles.gameScreen]}>
                    <View style={styles.errorBox}>
                        <View style={styles.errorTitleBox}>
                            <Text style={[CommonStyles.largeText, CommonStyles.textLose, styles.errorTitle]}>
                                No Questions Downloaded
                            </Text>
                        </View>

                        <View style={styles.errorContentBox}>
                            <Text style={[CommonStyles.baseText, styles.errorText]}>
                                Please try closing the app and opening it again when you have internet access.
                            </Text>
                        </View>
                    </View><commit_msg>don't access question if it doesn't exist<commit_after>
'use strict';

import React, {
    AppRegistry,
    Component,
    StyleSheet,
    Text,
    Image,
    View,
    TouchableHighlight,
    TouchableNativeFeedback,
    Platform,
} from 'react-native';

import SimpleStore from 'react-native-simple-store';

import AnswerScreen from './answer-screen';
import CommonStyles from './common-styles.js';
import TweetBox from './tweet-box.js';
import Toolbar from './toolbar.js';
import API from './api.js';
import Constants from './constants.js';

var TouchableElement = TouchableHighlight;
if (Platform.OS === 'android') {
    TouchableElement = TouchableNativeFeedback;
}

class QuestionScreen extends Component {
    constructor(props) {
        super(props);
        this.state = { question: null, currentStreak: null };
    }

    componentWillMount() {
        SimpleStore.get('questions').then((questions) => {
            var question = this.pickRandomQuestion(questions);
            if (question) {
                question.options = this.shuffleArray(question.options);
                this.setState(Object.assign(this.state, { question: question }));
            }
        });

        SimpleStore.get('currentStreak').then((currentStreak) => {
            SimpleStore.get('bestStreak').then((bestStreak) => {
                bestStreak = bestStreak || 0;
                this.setState(Object.assign(this.state, {
                    currentStreak: currentStreak,
                    bestStreak: bestStreak,
                }));
            });
        });
    }

    render() {
        if (!this.state.question) {
            return (
                <View style={[CommonStyles.screenBackground, styles.gameScreen]}>
                    <View style={styles.errorBox}>
                        <View style={styles.errorTitleBox}>
                            <Text style={[CommonStyles.largeText, CommonStyles.textLose, styles.errorTitle]}>
                                No Questions Downloaded
                            </Text>
                        </View>

                        <View style={styles.errorContentBox}>
                            <Text style={[CommonStyles.baseText, styles.errorText]}>
                                Please try closing the app and opening it again when you have internet access.
                            </Text>
                        </View>
                    </View>
{'fraction_non_alphanumeric': 0.11180904522613065, 'fraction_numerical': 0.0004187604690117253, 'mean_word_length': 1.7984768599882834, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4196210', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1203, 'n_words': 257}