<commit_before>
export default Ember.Component.extend({
  classNames: ['babble-post-composer'],

  _init: function() {
    this.set('placeholder', I18n.t('babble.placeholder'))
  }.on('init'),

  keyDown: function(event) {
    if (event.keyCode == 13) {
      this._actions.submit(this) // submit on enter
      return false
    }
  },

  textValidation: function() {
    var validation = { ok: true };
    if (Ember.isEmpty(this.get('text')))
      var validation = { failed: true };
    }

    return Discourse.InputValidation.create(validation);
  }.property('text'),

  submitDisabled: function() {
    if (this.get('textValidation.failed')) return true;
  }.property('textValidation'),

  actions: {
    submit: function(context) {
      var self = context || this;
      Discourse.ajax("/babble/topic/post", {
        type: 'POST',
        data: { raw: self.get('text') }
      }).then(function(data) {
        Discourse.Babble.refresh(data)
        self.set('text', '')
      });
    }
  }

});
<commit_msg>Fix broken composer validation<commit_after>
export default Ember.Component.extend({
  classNames: ['babble-post-composer'],

  _init: function() {
    this.set('placeholder', I18n.t('babble.placeholder'))
  }.on('init'),

  keyDown: function(event) {
    if (event.keyCode == 13) {
      this._actions.submit(this) // submit on enter
      return false
    }
  },

  textValidation: function() {
    var validation = { ok: true }
    if (Ember.isEmpty(this.get('text'))) {
      var validation = { failed: true }
    }

    return Discourse.InputValidation.create(validation)
  }.property('text'),

  submitDisabled: function() {
    if (this.get('textValidation.failed')) return true
  }.property('textValidation'),

  actions: {
    submit: function(context) {
      var self = context || this;
      Discourse.ajax("/babble/topic/post", {
        type: 'POST',
        data: { raw: self.get('text') }
      }).then(function(data) {
        Discourse.Babble.refresh(data)
        self.set('text', '')
      });
    }
  }

});

{'fraction_non_alphanumeric': 0.1678903573176701, 'fraction_numerical': 0.003915810083210965, 'mean_word_length': 2.8638941398865785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2141655', 'n_tokens_mistral': 664, 'n_tokens_neox': 631, 'n_words': 123}