<commit_before>import React, { Component } from 'react';
import {
	View,
	Text,
	Switch,
} from 'react-native';

import { connect } from 'react-redux';

import { setCardState } from '../../actions';
import Card from '../card/Card';
import css from '../../styles/css';

// View for user to manage preferences, including which cards are visible
export default class CardPreferences extends Component {
	_setCardState = (card, state) => {
		this.props.dispatch(setCardState(card, state));
	}

	// render out all the cards, currently showing or not
	_renderCards = () => {
		return Object.keys(this.props.cards).map(key => {

			const cardActive = this.props.cards[key].active;
			const cardName = this.props.cards[key].name;

			return (
				<View key={key} style={css.preferencesContainer}>
					<View style={css.spacedRow}>
						<View style={css.centerAlign}>
							<Text style={css.prefCardTitle}>{cardName}</Text>
						</View>
						<View style={css.centerAlign}>
							<Switch
								onValueChange={(value) => { this._setCardState(key, value) }}
								value={cardActive}
							/>
						</View>
					</View>
				</View>
			);
		});
	}

	render() {
		return (
			<Card id="cards" title="Cards" hideMenu={true}>
				<View style={css.card_content_full_width}>
					<View style={css.column}>
						{this._renderCards()}
					</View>
				</View>
			</Card>
		);
	}
}

function mapStateToProps(state, props) {
	return {
		cards: state.cards,
	};
}

module.exports = connect(mapStateToProps)(CardPreferences);<commit_msg>Reset Home scroll on preference change<commit_after>import React, { Component } from 'react';
import {
	View,
	Text,
	Switch,
} from 'react-native';

import { connect } from 'react-redux';

import { setCardState } from '../../actions';
import Card from '../card/Card';
import css from '../../styles/css';

// View for user to manage preferences, including which cards are visible
export default class CardPreferences extends Component {
	_setCardState = (card, state) => {
		this.props.setCardState(card, state);
		this.props.updateScroll(); // reset homeview scroll
	}

	// render out all the cards, currently showing or not
	_renderCards = () => {
		return Object.keys(this.props.cards).map(key => {

			const cardActive = this.props.cards[key].active;
			const cardName = this.props.cards[key].name;

			return (
				<View key={key} style={css.preferencesContainer}>
					<View style={css.spacedRow}>
						<View style={css.centerAlign}>
							<Text style={css.prefCardTitle}>{cardName}</Text>
						</View>
						<View style={css.centerAlign}>
							<Switch
								onValueChange={(value) => { this._setCardState(key, value); }}
								value={cardActive}
							/>
						</View>
					</View>
				</View>
			);
		});
	}

	render() {
		return (
			<Card id="cards" title="Cards" hideMenu={true}>
				<View style={css.card_content_full_width}>
					<View style={css.column}>
						{this._renderCards()}
					</View>
				</View>
			</Card>
		);
	}
}

function mapStateToProps(state, props) {
	return {
		cards: state.cards,
	};
}

function mapDispatchtoProps(dispatch) {
	return {
		setCardState: (card, state) => {
			dispatch(setCardState(card, state));
		},
		updateScroll: () => {
			dispatch({ type: 'UPDATE_HOME_SCROLL', scrollY: 0 });
		}
	};
}

module.exports = connect(mapStateToProps, mapDispatchtoProps)(CardPreferences);
{'fraction_non_alphanumeric': 0.15902322811197142, 'fraction_numerical': 0.0002977963073257892, 'mean_word_length': 3.31193838254172, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 47, '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': '6425727', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1071, 'n_words': 243}