<commit_before>import Ember from 'ember';
import { task } from 'ember-concurrency';

export default Ember.Component.extend({
  store: Ember.inject.service(),
  flashMessages: Ember.inject.service(),
  isDisabled: false,
  isSelected: Ember.computed(
    'member',
    '<EMAIL>',
    function(){
      let mapped = this.get('participants').mapBy('member.id');
      if (mapped.includes(this.get('member.id'))) {
        return true;
      } else {
        return false;
      }
  }),
  toggleParticipant: task(function* (property, value){
    if (value) {
      let newParticipant = this.get('store').createRecord('participant', {
        member: this.get('member'),
        entry: this.get('model'),
      });
      try {
        yield newParticipant.save();
        this.get('flashMessages').success("Saved");
      } catch(e) {
        e.errors.forEach((error) => {
          this.get('flashMessages').danger(error.detail);
        });
        newParticipant.deleteRecord();
      }
    } else {
      let participant = this.get('model.participants').findBy('contest.id', this.get('contest.id'));
      if (participant) {
        try {
          yield participant.destroyRecord();
          this.get('flashMessages').success("Saved");
        } catch(e) {
          e.errors.forEach((error) => {
            this.get('flashMessages').danger(error.detail);
          });
        }
      }
    }
  }).restartable(),
});
<commit_msg>Fix double-no clicking on participants<commit_after>import Ember from 'ember';
import { task } from 'ember-concurrency';

export default Ember.Component.extend({
  store: Ember.inject.service(),
  flashMessages: Ember.inject.service(),
  isDisabled: false,
  isSelected: Ember.computed(
    'member',
    '<EMAIL>',
    function(){
      let mapped = this.get('participants').mapBy('member.id');
      if (mapped.includes(this.get('member.id'))) {
        return true;
      } else {
        return false;
      }
  }),
  toggleParticipant: task(function* (property, value){
    if (value) {
      let newParticipant = this.get('store').createRecord('participant', {
        member: this.get('member'),
        entry: this.get('model'),
      });
      try {
        yield newParticipant.save();
        this.get('flashMessages').success("Saved");
      } catch(e) {
        e.errors.forEach((error) => {
          this.get('flashMessages').danger(error.detail);
        });
        newParticipant.deleteRecord();
      }
    } else {
      let participant = this.get('model.participants').findBy('member.id', this.get('member.id'));
      if (participant) {
        try {
          yield participant.destroyRecord();
          this.get('flashMessages').success("Saved");
        } catch(e) {
          e.errors.forEach((error) => {
            this.get('flashMessages').danger(error.detail);
          });
        }
      }
    }
  }).restartable(),
});

{'fraction_non_alphanumeric': 0.16730169726359542, 'fraction_numerical': 0.0, 'mean_word_length': 2.4795180722891565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5092765', 'n_tokens_mistral': 869, 'n_tokens_neox': 852, 'n_words': 140}