fix suggested subscriptions state handling
This commit is contained in:
parent
0536f0e4bf
commit
bcfb65ed54
1 changed files with 16 additions and 5 deletions
|
@ -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 {
|
||||||
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,9 +67,18 @@ class SuggestedSubscriptionsGrid extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { claimSearch, followedTags, showNsfwContent } = this.props;
|
const { claimSearch, followedTags, showNsfwContent, subscriptions } = this.props;
|
||||||
|
if (subscriptions && subscriptions.length > 0) {
|
||||||
|
this.setState(
|
||||||
|
{
|
||||||
|
subscriptionIds: subscriptions.map(subscription => subscription.uri.split('#')[1]),
|
||||||
|
},
|
||||||
|
() => this.doClaimSearch(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
this.doClaimSearch();
|
this.doClaimSearch();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { claimSearchByQuery, suggested, inModal, navigation } = this.props;
|
const { claimSearchByQuery, suggested, inModal, navigation } = this.props;
|
||||||
|
|
Loading…
Reference in a new issue