Use _ prefix for private methods

This commit is contained in:
Luke Barnard 2016-11-10 14:12:05 +00:00
parent 8422017827
commit 370f5f0a11

View file

@ -45,20 +45,20 @@ module.exports = React.createClass({
}; };
}, },
toggleSummary: function() { _toggleSummary: function() {
this.setState({ this.setState({
expanded: !this.state.expanded, expanded: !this.state.expanded,
}); });
}, },
getEventSenderName: function(ev) { _getEventSenderName: function(ev) {
if (!ev) { if (!ev) {
return 'undefined'; return 'undefined';
} }
return ev.sender.name || ev.event.content.displayname || ev.getSender(); return ev.sender.name || ev.event.content.displayname || ev.getSender();
}, },
renderNameList: function(events) { _renderNameList: function(events) {
if (events.length === 0) { if (events.length === 0) {
return null; return null;
} }
@ -67,11 +67,11 @@ module.exports = React.createClass({
let lastEvent = events.pop(); let lastEvent = events.pop();
let names = events.map((ev) => { let names = events.map((ev) => {
return this.getEventSenderName(ev); return this._getEventSenderName(ev);
}).join(', '); }).join(', ');
if (names.length === 0) { if (names.length === 0) {
return this.getEventSenderName(lastEvent); return this._getEventSenderName(lastEvent);
} }
// Special case the last name. ' and ' might be included later // Special case the last name. ' and ' might be included later
@ -83,13 +83,13 @@ module.exports = React.createClass({
// name1, name2, name3 [and 100 others] // name1, name2, name3 [and 100 others]
names += ', '; names += ', ';
} }
return names + this.getEventSenderName(lastEvent); return names + this._getEventSenderName(lastEvent);
}, },
renderSummary: function(joinEvents, leaveEvents) { _renderSummary: function(joinEvents, leaveEvents) {
let joiners = this.renderNameList(joinEvents); let joiners = this._renderNameList(joinEvents);
let remainingJoiners = joinEvents.length - this.props.summaryLength; let remainingJoiners = joinEvents.length - this.props.summaryLength;
let leavers = this.renderNameList(leaveEvents); let leavers = this._renderNameList(leaveEvents);
let remainingLeavers = leaveEvents.length - this.props.summaryLength; let remainingLeavers = leaveEvents.length - this.props.summaryLength;
let joinSummary = null; let joinSummary = null;
if (joiners) { if (joiners) {
@ -115,7 +115,7 @@ module.exports = React.createClass({
); );
}, },
renderAvatars: function(events) { _renderAvatars: function(events) {
let avatars = events.slice(0, this.props.avatarsMaxLength).map((e) => { let avatars = events.slice(0, this.props.avatarsMaxLength).map((e) => {
let onClickAvatar = () => { let onClickAvatar = () => {
dispatcher.dispatch({ dispatcher.dispatch({
@ -180,14 +180,14 @@ module.exports = React.createClass({
expandedEvents = this.props.children; expandedEvents = this.props.children;
} }
let avatars = this.renderAvatars(joinEvents.concat(leaveEvents)); let avatars = this._renderAvatars(joinEvents.concat(leaveEvents));
let toggleButton = null; let toggleButton = null;
let summaryContainer = null; let summaryContainer = null;
if (!fewEvents) { if (!fewEvents) {
summary = this.renderSummary(joinEvents, leaveEvents); summary = this._renderSummary(joinEvents, leaveEvents);
toggleButton = ( toggleButton = (
<a onClick={this.toggleSummary} href="javascript:;">{expanded?'collapse':'expand'}</a> <a onClick={this._toggleSummary} href="javascript:;">{expanded?'collapse':'expand'}</a>
); );
let noun = (joinAndLeft === 1 ? 'user' : 'others'); let noun = (joinAndLeft === 1 ? 'user' : 'others');