<commit_before>// Deps
var PlaylistIndex = require("./PlaylistIndex.js.jsx");
var SubscriptionList = require("./SubscriptionList.js.jsx");
var React = require('react');
var _ = require('lodash');

// Component
var PlaylistContainer = React.createClass({
  getInitialState: function () {
    return {
      playlistId: null,
      playlistItem: {},
      subscriptions: []
    };
  },

  containerGetSubscriptionsForItem: function (playlistItem) {
    var playlistId = playlistItem.id;
        self = this,
        api = new prBumpsApi();

    api.getSubscriptions(playlistId).then(function (response) {
      self.setState({
        subscriptions: response,
        playlistId: playlistId,
        playlistItem: playlistItem
      })
    });
  },

  handleClickOnSubscriptionItem: function (playlistId, subscribed) {
    // update subscriptions.subscribed value for correct playlist
    var subscriptions = this.state.subscriptions;
    var playlist = _.find(subscriptions, {id: playlistId});
    playlist.subscribed = subscribed;
    this.setState({
      subscriptions: subscriptions<commit_msg>Track dirty state in form<commit_after>// Deps
var PlaylistIndex = require("./PlaylistIndex.js.jsx");
var SubscriptionList = require("./SubscriptionList.js.jsx");
var React = require('react');
var _ = require('lodash');

// Component
var PlaylistContainer = React.createClass({
  getInitialState: function () {
    return {
      playlistId: null,
      playlistItem: {},
      dirtySubscriptionsForm: false,
      subscriptions: [],
      masterSubscriptions: []
    };
  },

  containerGetSubscriptionsForItem: function (playlistItem) {
    var playlistId = playlistItem.id;
        self = this,
        api = new prBumpsApi();

    api.getSubscriptions(playlistId).then(function (response) {
      self.setState({
        masterSubscriptions: response,
        subscriptions: _.cloneDeep(response),
        playlistId: playlistId,
        playlistItem: playlistItem
      })
    });
  },

  isSubscriptionFormDirty: function (oldList, newList) {
    return !_.isEqual(oldList, newList);
  },

  handleClickOnSubscriptionItem: function (playlistId, subscribed) {
    // update subscriptions.subscribed value for correct playlist
    var newSubscriptions = this.state.subscriptions;
    var masterSubscriptions = this.state.masterSubscriptions;
    var playlist = _.find(newSubscriptions, {id: playlistId});

    // set value on playlistItem
    playlist.subscribed = subscribed;
    // check if value we are setting is different from original form
    var dirtyForm = this.isSubscriptionFormDirty(masterSubscriptions, newSubscriptions);
    // update state
    this.setState({
      subscriptions: newSubscriptions,
      dirtySubscriptionsForm: dirtyForm
{'fraction_non_alphanumeric': 0.10602759622367465, 'fraction_numerical': 0.0, 'mean_word_length': 3.486970684039088, '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': '254120', 'n_tokens_mistral': 777, 'n_tokens_neox': 776, 'n_words': 175}