Partial fix for not allowing someone to veto their own suggestion

This commit is contained in:
Aaron Lindsay 2017-01-01 21:15:22 -05:00
parent a395dacfef
commit d8fdf68cbb

View File

@ -34,11 +34,20 @@ module.exports = React.createClass({
pickNewAttendee: function(props) {
// Pick a new attendee if the current one can't be valid *and* we have
// a list of valid possibilities
// Find the last suggestion, if possible
var lastSuggestion = null;
var lastSuggestionId = this.getLastSuggestion();
if (this.props.suggestions.hasOwnProperty(lastSuggestionId))
lastSuggestion = this.props.suggestions[lastSuggestionId];
if (this.state.attendee == null ||
!props.attendees.hasOwnProperty(this.state.attendee.AttendeeId)) {
if (Object.keys(props.attendees).length >= 1) {
!props.attendees.hasOwnProperty(this.state.attendee.AttendeeId) ||
(lastSuggestion && lastSuggestion.AttendeeId == this.state.attendee.AttendeeId)) {
var attendeeList = this.getAttendeeList();
if (attendeeList.length >= 1) {
this.setState({
attendee: props.attendees[Object.keys(props.attendees)[0]]
attendee: attendeeList[0]
});
} else {
this.setState({
@ -49,8 +58,15 @@ module.exports = React.createClass({
},
getAttendeeList: function() {
var attendeeList = [];
var lastSuggestion = null;
var lastSuggestionId = this.getLastSuggestion();
if (this.props.suggestions.hasOwnProperty(lastSuggestionId))
lastSuggestion = this.props.suggestions[lastSuggestionId];
for (var attendeeId in this.props.attendees) {
attendeeList.push(this.props.attendees[attendeeId]);
if (!lastSuggestion || lastSuggestion.AttendeeId != parseInt(attendeeId, 10))
attendeeList.push(this.props.attendees[attendeeId]);
}
return attendeeList;
},