<commit_before>/*
Copyright 2015, 2016 OpenMarket Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
 * State vars:
 * 'can': {
 *   kick: boolean,
 *   ban: boolean,
 *   mute: boolean,
 *   modifyLevel: boolean
 * },
 * 'muted': boolean,
 * 'isTargetMod': boolean
 */
var React = require('react');
var MatrixClientPeg = require("../../../MatrixClientPeg");
var dis = require("../../../dispatcher");
var Modal = require("../../../Modal");
var sdk = require('../../../index');
var UserSettingsStore = require('../../../UserSettingsStore');
var createRoom = require('../../../createRoom');

module.exports = React.createClass({
    displayName: 'MemberInfo',

    propTypes: {
        member: React.PropTypes.object.isRequired,
        onFinished: React.PropTypes.func,
    },

    getDefaultProps: function() {
        return {
            onFinished: function() {}
        };
    },

    getInitialState: function() {
        return {
            can: {
                kick: false,
                ban: false,
                mute: false,
                modifyLevel: false
            },
            muted: false,
            isTargetMod: false,
            updating: 0,
            devicesLoading: true,
            devices: null,
            existingOneToOneRoomId: null,
        }
    },

    componentWillMount: function() {
        this._cancelDeviceList = null;

        this.setState({
            existingOneToOneRoomId: this.getExistingOneToOneRoomId()
        });
    },

    componentDidMount: function() {
        // only display the devices list if our client supports E2E *and* the
        // feature is enabled in the user settings
        this._enableDevices = MatrixClientPeg.get().isCryptoEnabled() &&
            UserSettingsStore.isFeatureEnabled("e2e_encryption");

        this._updateStateForNewMember(this.props.member);
        MatrixClientPeg.get().on("deviceVerificationChanged", this.onDeviceVerificationChanged);
    },

    componentWillReceiveProps: function(newProps) {
        if (this.props.member.userId != newProps.member.userId) {
            this._updateStateForNewMember(newProps.member);
        }
    },

    componentWillUnmount: function() {
        var client = MatrixClientPeg.get();
        if (client) {
            client.removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged);
        }<commit_msg>MemberInfo: initialise _enableDevices in componentWillMount<commit_after>/*
Copyright 2015, 2016 OpenMarket Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
 * State vars:
 * 'can': {
 *   kick: boolean,
 *   ban: boolean,
 *   mute: boolean,
 *   modifyLevel: boolean
 * },
 * 'muted': boolean,
 * 'isTargetMod': boolean
 */
var React = require('react');
var MatrixClientPeg = require("../../../MatrixClientPeg");
var dis = require("../../../dispatcher");
var Modal = require("../../../Modal");
var sdk = require('../../../index');
var UserSettingsStore = require('../../../UserSettingsStore');
var createRoom = require('../../../createRoom');

module.exports = React.createClass({
    displayName: 'MemberInfo',

    propTypes: {
        member: React.PropTypes.object.isRequired,
        onFinished: React.PropTypes.func,
    },

    getDefaultProps: function() {
        return {
            onFinished: function() {}
        };
    },

    getInitialState: function() {
        return {
            can: {
                kick: false,
                ban: false,
                mute: false,
                modifyLevel: false
            },
            muted: false,
            isTargetMod: false,
            updating: 0,
            devicesLoading: true,
            devices: null,
            existingOneToOneRoomId: null,
        }
    },

    componentWillMount: function() {
        this._cancelDeviceList = null;

        // only display the devices list if our client supports E2E *and* the
        // feature is enabled in the user settings
        this._enableDevices = MatrixClientPeg.get().isCryptoEnabled() &&
            UserSettingsStore.isFeatureEnabled("e2e_encryption");

        this.setState({
            existingOneToOneRoomId: this.getExistingOneToOneRoomId()
        });
    },

    componentDidMount: function() {
        this._updateStateForNewMember(this.props.member);
        MatrixClientPeg.get().on("deviceVerificationChanged", this.onDeviceVerificationChanged);
    },

    componentWillReceiveProps: function(newProps) {
        if (this.props.member.userId != newProps.member.userId) {
            this._updateStateForNewMember(newProps.member);
        }
    },

    componentWillUnmount: function() {
        var client = MatrixClientPeg.get();
        if (client) {
            client.removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged);
        }
{'fraction_non_alphanumeric': 0.11679972231863936, 'fraction_numerical': 0.0052065255119750084, 'mean_word_length': 2.469596628537026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1873431', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1511, 'n_words': 418}