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 = {
|
||||
currentPage: 1,
|
||||
options: {},
|
||||
// maintain a local state of subscriptions so that changes don't affect the search
|
||||
subscriptionIds: [],
|
||||
};
|
||||
|
||||
buildClaimSearchOptions() {
|
||||
const { showNsfwContent, subscriptions } = this.props;
|
||||
const { showNsfwContent } = this.props;
|
||||
const { currentPage } = this.state;
|
||||
|
||||
const options = {
|
||||
|
@ -34,8 +36,8 @@ class SuggestedSubscriptionsGrid extends React.PureComponent {
|
|||
if (!showNsfwContent) {
|
||||
options.not_tags = MATURE_TAGS;
|
||||
}
|
||||
if (subscriptions && subscriptions.length > 0) {
|
||||
options.not_channel_ids = subscriptions.map(subscription => subscription.uri.split('#')[1]);
|
||||
if (this.state.subscriptionIds.length > 0) {
|
||||
options.not_channel_ids = this.state.subscriptionIds;
|
||||
}
|
||||
|
||||
return options;
|
||||
|
@ -65,9 +67,18 @@ class SuggestedSubscriptionsGrid extends React.PureComponent {
|
|||
};
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { claimSearchByQuery, suggested, inModal, navigation } = this.props;
|
||||
|
|
Loading…
Reference in a new issue