Updated componentWillReceiveProps

This commit is contained in:
Belen Curcio
2017-07-31 13:18:54 -03:00
parent 31112b3a20
commit 4079a74ab8
2 changed files with 30 additions and 13 deletions
@@ -7,7 +7,7 @@ import ModerationMenu from './ModerationMenu';
import ModerationHeader from './ModerationHeader';
import ModerationKeysModal from '../../../components/ModerationKeysModal';
import StorySearch from '../containers/StorySearch';
import {isPremod, getModPath} from '../../../utils';
import {isPremod} from '../../../utils';
export default class Moderation extends Component {
constructor() {
@@ -104,7 +104,7 @@ export default class Moderation extends Component {
const {root, moderation, settings, viewUserDetail, hideUserDetail, activeTab, getModPath, ...props} = this.props;
const assetId = this.props.params.id;
const {asset} = root;
console.log(activeTab)
const comments = root[activeTab];
let activeTabCount;
@@ -141,21 +141,38 @@ class ModerationContainer extends Component {
componentWillReceiveProps(nextProps) {
// Will update the URL to `premod` or `new` based on the moderation of the *asset*
// If there are a reported comments, the `reported` queue has priority!
if (nextProps.root) {
const {router, route, root} = nextProps;
if (router.location.pathname === 'admin/moderate' && root.settings) {
const queue = isPremod(root.settings.moderation) ? 'premod' : 'new';
console.log('PUSHING ROUTE', getModPath(root.reportedCount ? 'reported' : queue));
router.push(
getModPath(root.reportedCount ? 'reported' : queue)
);
}
if (route.path === ':id' && root.asset) {
console.log(root.asset.settings.moderation)
const queue = isPremod(root.asset.settings.moderation) ? 'premod' : 'new';
console.log('PUSHING ROUTE', getModPath(root.reportedCount ? 'reported' : queue));
router.push(
getModPath(root.reportedCount ? 'reported' : queue, router.params.id)
);
}
}
// Resubscribe when we change between assets.
if(this.props.data.variables.asset_id !== nextProps.data.variables.asset_id) {
this.resubscribe(nextProps.data.variables);
}
// const {router, route, root: {asset, reportedCount}} = this.props;
// // Will update the URL to premod or new based on the moderation of the *asset*
// // If there is a reported comments, reported queue has priority!
// if (route.path === ':id') {
// const queue = isPremod(asset.settings.moderation) ? 'premod' : 'new';
// router.push(
// getModPath(reportedCount ? 'reported' : queue, asset.id)
// );
// }
}
acceptComment = ({commentId}) => {