<commit_before>import React from 'react';
import { Text, View, TouchableHighlight, Alert } from 'react-native';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import PropTypes from 'prop-types';
import Store from 'react-native-simple-store';
import styles from './styles/SettingsStyles';
import { ActionCreators } from '../actions';

class Settings extends React.Component {
    resetLevel() {
        Alert.alert(
            'Clear Progress?',
            'Are you sure you want to do that? This action will reset your level to 1',
            [
                { text: 'Cancel', onPress: () => {}, style: 'cancel' },
                { text: 'Confirm', onPress: () => this.resetLevelConfirmed() },
            ],
            { cancelable: false },
        );
        this.props.setLevel(1);
        Store.save('level', 1);
    }

    resetLevelConfirmed() {
        this.props.setLevel(1);
        Store.save('level', 1);
    }

    render() {
        const triColor = this.props.triColorMode ? 'ON' : 'OFF';

        return (
            <View style={styles.settings}>
                <View style={styles.settings_header}>
                    <TouchableHighlight
                      style={styles.menuButton}
                      underlayColor="#CECDCD"
                      activeOpacity={0.5}
                      onPress={() => this.props.setCompleteRoute('menu')}
                    >
                        <View style={styles.menuContainer}>
                            <View style={styles.backToMenu}>
                                <Text style={styles.menuText}>MENU</Text>
                            </View>
                        </View>
                    </TouchableHighlight>
                    <View style={styles.settingsElement}>
                        <View style={styles.menuContainer}>
                            <View style={styles.settingsBox}>
                                <Text style={[styles.menuText, styles.settingsText]}>
                                    SETTINGS
                                </Text>
                            </View>
                        </View>
                    </View>
                </View>
                <View style={{ flex: 7, marginBottom: 30, width: '90%' }}>
                    <View style={styles.menu}>
                        <TouchableHighlight
                          underlayColor="white"
                          activeOpacity={0.5}
                          style={styles.settingsButton}
                          onPress={() => this.props.setTriColorMode(!this.props.triColorMode)}
                        >
                            <Text style={styles.settingsButtonText}>TRICOLOR MODE :&nbsp;
                                <Text style={styles.triColorStatus}>{triColor}</Text>
                            </Text>
                        </TouchableHighlight>
                        <TouchableHighlight
                          underlayColor="white"
                          activeOpacity={0.5}
                          style={styles.settingsButton}
                          onPress={() => this.resetLevel()} // todo: add modal
                        >
                            <Text style={styles.progressText}>CLEAR PROGRESS</Text>
                        </TouchableHighlight>
                    </View>
                </View>
            </View>
        );
    }
}

Settings.propTypes = {
    triColorMode: PropTypes.bool.isRequired,
    setTriColorMode: PropTypes.func.isRequired,
    setCompleteRoute: PropTypes.func.isRequired,
    setLevel: PropTypes.func.isRequired,
};
<commit_msg>fix bug where boardStateCache isn't cleared when you reset progress<commit_after>import React from 'react';
import { Text, View, TouchableHighlight, Alert } from 'react-native';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import PropTypes from 'prop-types';
import Store from 'react-native-simple-store';
import styles from './styles/SettingsStyles';
import { ActionCreators } from '../actions';

class Settings extends React.Component {
    resetLevel() {
        Alert.alert(
            'Clear Progress?',
            'Are you sure you want to do that? This action will reset your level to 1',
            [
                { text: 'Cancel', onPress: () => {}, style: 'cancel' },
                { text: 'Confirm', onPress: () => this.resetLevelConfirmed() },
            ],
            { cancelable: false },
        );
    }

    resetLevelConfirmed() {
        Store.save('level', 1);
        this.props.setLevel(1);
        this.props.setBoardStateCache(null);
    }

    render() {
        const triColor = this.props.triColorMode ? 'ON' : 'OFF';

        return (
            <View style={styles.settings}>
                <View style={styles.settings_header}>
                    <TouchableHighlight
                      style={styles.menuButton}
                      underlayColor="#CECDCD"
                      activeOpacity={0.5}
                      onPress={() => this.props.setCompleteRoute('menu')}
                    >
                        <View style={styles.menuContainer}>
                            <View style={styles.backToMenu}>
                                <Text style={styles.menuText}>MENU</Text>
                            </View>
                        </View>
                    </TouchableHighlight>
                    <View style={styles.settingsElement}>
                        <View style={styles.menuContainer}>
                            <View style={styles.settingsBox}>
                                <Text style={[styles.menuText, styles.settingsText]}>
                                    SETTINGS
                                </Text>
                            </View>
                        </View>
                    </View>
                </View>
                <View style={{ flex: 7, marginBottom: 30, width: '90%' }}>
                    <View style={styles.menu}>
                        <TouchableHighlight
                          underlayColor="white"
                          activeOpacity={0.5}
                          style={styles.settingsButton}
                          onPress={() => this.props.setTriColorMode(!this.props.triColorMode)}
                        >
                            <Text style={styles.settingsButtonText}>TRICOLOR MODE :&nbsp;
                                <Text style={styles.triColorStatus}>{triColor}</Text>
                            </Text>
                        </TouchableHighlight>
                        <TouchableHighlight
                          underlayColor="white"
                          activeOpacity={0.5}
                          style={styles.settingsButton}
                          onPress={() => this.resetLevel()} // todo: add modal
                        >
                            <Text style={styles.progressText}>CLEAR PROGRESS</Text>
                        </TouchableHighlight>
                    </View>
                </View>
            </View>
        );
    }
}

Settings.propTypes = {
    triColorMode: PropTypes.bool.isRequired,
    setTriColorMode: PropTypes.func.isRequired,
    setCompleteRoute: PropTypes.func.isRequired,
    setLevel: PropTypes.func.isRequired,
    setBoardStateCache: PropTypes.func.isRequired,
};

{'fraction_non_alphanumeric': 0.11029810298102981, 'fraction_numerical': 0.0040650406504065045, 'mean_word_length': 1.2675883256528417, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6687607', 'n_tokens_mistral': 1795, 'n_tokens_neox': 1711, 'n_words': 343}