"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _spin = require("antd/es/spin");

var _spin2 = _interopRequireDefault(_spin);

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

require("antd/es/spin/style/css");

var _react = require("react");

var _react2 = _interopRequireDefault(_react);

var _Comment = require("../../Comment");

var _Comment2 = _interopRequireDefault(_Comment);

var _CommentBox = require("../CommentBox");

var _CommentBox2 = _interopRequireDefault(_CommentBox);

require("./index.css");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var CommentList = function (_Component) {
  _inherits(CommentList, _Component);

  function CommentList(props) {
    _classCallCheck(this, CommentList);

    var _this = _possibleConstructorReturn(this, (CommentList.__proto__ || Object.getPrototypeOf(CommentList)).call(this, props));

    _this.state = {};
    return _this;
  }

  _createClass(CommentList, [{
    key: "componentWillMount",
    value: function componentWillMount() {
      this.props.app.sGetComment();
    }
  }, {
    key: "render",
    value: function render() {
      var _props$app = this.props.app,
          list = _props$app.list,
          total = _props$app.total,
          page = _props$app.page,
          loading = _props$app.loading,
          isNoMoreComment = _props$app.isNoMoreComment,
          sGetComment = _props$app.sGetComment;


      var spinning = Boolean(loading.sGetComment || loading.sCommentFavor || loading.sReplyFavor);
      return _react2.default.createElement(
        "div",
        null,
        _react2.default.createElement(
          _spin2.default,
          { spinning: spinning },
          _react2.default.createElement(
            "div",
            null,
            "\u5171 ",
            total,
            " \u6761\u8BC4\u8BBA"
          ),
          list.map(function (item) {
            return _react2.default.createElement(_CommentBox2.default, { content: item, key: item.id, commentId: item.id });
          }),
          !isNoMoreComment && list.length !== total && _react2.default.createElement(
            "div",
            {
              className: "comment-list-show-more",
              onClick: function onClick() {
                return sGetComment({ page: page + 1 });
              }
            },
            _react2.default.createElement(
              "span",
              null,
              "\u67E5\u770B\u66F4\u591A\u8BC4\u8BBA"
            )
          )
        )
      );
    }
  }]);

  return CommentList;
}(_react.Component);

CommentList.propTypes = {};

exports.default = (0, _Comment2.default)(CommentList);
//# sourceMappingURL=index.js.map