<commit_before>import React from "react-native";
import RoomItem from "../components/room-item";
import controller from "./controller";

const {
	InteractionManager
} = React;

@controller
export default class RoomItemController extends React.Component {
	constructor(props) {
		super(props);

		this.state = {
			role: "none"
		};
	}

	componentDidMount() {
		this._updateData();

		this.handle("statechange", changes => {
			const user = this.store.get("user");

			if (changes.entities && changes.entities[this.props.room.id + "_" + user]) {
				this._updateData();
			}
		});
	}

	_updateData() {
		InteractionManager.runAfterInteractions(() => {
			if (this._mounted) {
				const role = this.store.getUserRole(this.store.get("user"), this.props.room.id);

				this.setState({
					role: role === "registered" || !role ? "none" : role
				});
			}
		});
	}

	_joinCommunity() {
		this.dispatch("join", {
			to: this.props.room.id
		});
	}

	_leaveCommunity() {
		this.dispatch("part", {
			to: this.props.room.id
		});
	}

	render() {
		return (
			<RoomItem
				{...this.props}
				{...this.state}
				joinCommunity={this._joinCommunity.bind(this)}<commit_msg>Send away for room when leaving room<commit_after>import React from "react-native";
import RoomItem from "../components/room-item";
import controller from "./controller";

const {
	InteractionManager
} = React;

@controller
export default class RoomItemController extends React.Component {
	constructor(props) {
		super(props);

		this.state = {
			role: "none"
		};
	}

	componentDidMount() {
		this._updateData();

		this.handle("statechange", changes => {
			const user = this.store.get("user");

			if (changes.entities && changes.entities[this.props.room.id + "_" + user]) {
				this._updateData();
			}
		});
	}

	_updateData() {
		InteractionManager.runAfterInteractions(() => {
			if (this._mounted) {
				const role = this.store.getUserRole(this.store.get("user"), this.props.room.id);

				this.setState({
					role: role === "registered" || !role ? "none" : role
				});
			}
		});
	}

	_joinCommunity() {
		this.dispatch("join", {
			to: this.props.room.id
		});
	}

	_leaveCommunity() {
		const room = this.props.room.id;

		this.dispatch("part", {
			to: room
		})
		.then(() => {
			return this.dispatch("away", {
				to: room
			});
		});
	}

	render() {
		return (
			<RoomItem
				{...this.props}
				{...this.state}
				joinCommunity={this._joinCommunity.bind(this)}
{'fraction_non_alphanumeric': 0.17346938775510204, 'fraction_numerical': 0.0, 'mean_word_length': 3.2552083333333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '515409', 'n_tokens_mistral': 961, 'n_tokens_neox': 813, 'n_words': 149}