'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.setReadProgress = setReadProgress;
exports.setPageType = setPageType;
exports.setPageTitle = setPageTitle;
exports.setArticleTopicList = setArticleTopicList;

var _actionTypes = require('../constants/action-types');

var types = _interopRequireWildcard(_actionTypes);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

function setReadProgress(percent) {
  if (!percent || percent < 0) {
    percent = 0;
  } else if (percent > 100) {
    percent = 100;
  }

  return {
    type: types.SET_PROGRESS_PRECENTAGE,
    percent: percent
  };
}

function setPageType(pageType) {
  return {
    type: types.SET_PAGE_TYPE,
    pageType: pageType
  };
}

function setPageTitle(articleId, pageTitle) {
  var pageTopic = arguments.length <= 2 || arguments[2] === undefined ? null : arguments[2];

  return {
    type: types.SET_PAGE_TITLE,
    articleId: articleId,
    pageTitle: pageTitle,
    pageTopic: pageTopic
  };
}

function setArticleTopicList(topicArr) {
  return {
    type: types.SET_ARTICLE_TOPIC_LIST,
    topicArr: topicArr
  };
}