Commit bcfb65ed authored by Akinwale Ariwodola's avatar Akinwale Ariwodola
Browse files

fix suggested subscriptions state handling

parent 0536f0e4
...@@ -18,10 +18,12 @@ class SuggestedSubscriptionsGrid extends React.PureComponent { ...@@ -18,10 +18,12 @@ class SuggestedSubscriptionsGrid extends React.PureComponent {
state = { state = {
currentPage: 1, currentPage: 1,
options: {}, options: {},
// maintain a local state of subscriptions so that changes don't affect the search
subscriptionIds: [],
}; };
buildClaimSearchOptions() { buildClaimSearchOptions() {
const { showNsfwContent, subscriptions } = this.props; const { showNsfwContent } = this.props;
const { currentPage } = this.state; const { currentPage } = this.state;
const options = { const options = {
...@@ -34,8 +36,8 @@ class SuggestedSubscriptionsGrid extends React.PureComponent { ...@@ -34,8 +36,8 @@ class SuggestedSubscriptionsGrid extends React.PureComponent {
if (!showNsfwContent) { if (!showNsfwContent) {
options.not_tags = MATURE_TAGS; options.not_tags = MATURE_TAGS;
} }
if (subscriptions && subscriptions.length > 0) { if (this.state.subscriptionIds.length > 0) {
options.not_channel_ids = subscriptions.map(subscription => subscription.uri.split('#')[1]); options.not_channel_ids = this.state.subscriptionIds;
} }
return options; return options;
...@@ -65,8 +67,17 @@ class SuggestedSubscriptionsGrid extends React.PureComponent { ...@@ -65,8 +67,17 @@ class SuggestedSubscriptionsGrid extends React.PureComponent {
}; };
componentDidMount() { componentDidMount() {
const { claimSearch, followedTags, showNsfwContent } = this.props; const { claimSearch, followedTags, showNsfwContent, subscriptions } = this.props;
this.doClaimSearch(); if (subscriptions && subscriptions.length > 0) {
this.setState(
{
subscriptionIds: subscriptions.map(subscription => subscription.uri.split('#')[1]),
},
() => this.doClaimSearch(),
);
} else {
this.doClaimSearch();
}
} }
render() { render() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment