Listing setParam only needs to be run when url history is specified

- added missing code to deleteManySubscriptions() so that it doesn't remove from all segments
This commit is contained in:
Jonathan Labreuille
2016-06-20 17:28:19 +02:00
parent 674bbd728e
commit b87754ca30
2 changed files with 40 additions and 35 deletions

View File

@ -365,6 +365,7 @@ const Listing = React.createClass({
}.bind(this)); }.bind(this));
}, },
setParams: function() { setParams: function() {
if (this.props.location) {
let params = Object.keys(this.state) let params = Object.keys(this.state)
.filter(key => { .filter(key => {
return ( return (
@ -393,14 +394,13 @@ const Listing = React.createClass({
.filter(key => { return (key !== undefined) }) .filter(key => { return (key !== undefined) })
.join('/'); .join('/');
// prepend with tab is specified // prepend url with "tab" if specified
if (this.props.tab !== undefined) { if (this.props.tab !== undefined) {
params = `/${ this.props.tab }/${ params }`; params = `/${ this.props.tab }/${ params }`;
} else { } else {
params = `/${ params }`; params = `/${ params }`;
} }
if (this.props.location) {
if (this.props.location.pathname !== params) { if (this.props.location.pathname !== params) {
this.context.router.push(`${params}`); this.context.router.push(`${params}`);
} }

View File

@ -129,6 +129,11 @@ class SubscriberSegment extends Model {
'segment_id', $wp_segment->id 'segment_id', $wp_segment->id
); );
} }
if(!empty($segment_ids)) {
$subscriptions = $subscriptions->whereIn('segment_id', $segment_ids);
}
return $subscriptions->deleteMany(); return $subscriptions->deleteMany();
} }