don't show notification for new subscription if on subscription page
This commit is contained in:
parent
e7a2bb1bba
commit
f900f53056
1 changed files with 8 additions and 2 deletions
|
@ -7,7 +7,7 @@ import type { Dispatch, SubscriptionNotifications } from 'redux/reducers/subscri
|
||||||
import type { Subscription } from 'types/subscription';
|
import type { Subscription } from 'types/subscription';
|
||||||
import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
||||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||||
import { Lbry, buildURI, parseURI } from 'lbry-redux';
|
import { Lbry, buildURI, parseURI, selectCurrentPage } from 'lbry-redux';
|
||||||
import { doPurchaseUri, doFetchClaimsByChannel } from 'redux/actions/content';
|
import { doPurchaseUri, doFetchClaimsByChannel } from 'redux/actions/content';
|
||||||
import { doClaimRewardType } from 'redux/actions/rewards';
|
import { doClaimRewardType } from 'redux/actions/rewards';
|
||||||
import Promise from 'bluebird';
|
import Promise from 'bluebird';
|
||||||
|
@ -133,6 +133,7 @@ export const doCheckSubscription = (subscriptionUri: string, notify?: boolean) =
|
||||||
// no dispatching FETCH_CHANNEL_CLAIMS_STARTED; causes loading issues on <SubscriptionsPage>
|
// no dispatching FETCH_CHANNEL_CLAIMS_STARTED; causes loading issues on <SubscriptionsPage>
|
||||||
|
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
const currentPage = selectCurrentPage(state);
|
||||||
const savedSubscription = state.subscriptions.subscriptions.find(
|
const savedSubscription = state.subscriptions.subscriptions.find(
|
||||||
sub => sub.uri === subscriptionUri
|
sub => sub.uri === subscriptionUri
|
||||||
);
|
);
|
||||||
|
@ -141,6 +142,11 @@ export const doCheckSubscription = (subscriptionUri: string, notify?: boolean) =
|
||||||
const claimResult = result[subscriptionUri] || {};
|
const claimResult = result[subscriptionUri] || {};
|
||||||
const { claims_in_channel: claimsInChannel } = claimResult;
|
const { claims_in_channel: claimsInChannel } = claimResult;
|
||||||
|
|
||||||
|
// may happen if subscribed to an abandoned channel or an empty channel
|
||||||
|
if (!claimsInChannel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const latestIndex = claimsInChannel.findIndex(
|
const latestIndex = claimsInChannel.findIndex(
|
||||||
claim => `${claim.name}#${claim.claim_id}` === savedSubscription.latest
|
claim => `${claim.name}#${claim.claim_id}` === savedSubscription.latest
|
||||||
);
|
);
|
||||||
|
@ -158,7 +164,7 @@ export const doCheckSubscription = (subscriptionUri: string, notify?: boolean) =
|
||||||
!claim.value.stream.metadata.fee &&
|
!claim.value.stream.metadata.fee &&
|
||||||
makeSelectClientSetting(SETTINGS.AUTO_DOWNLOAD)(state)
|
makeSelectClientSetting(SETTINGS.AUTO_DOWNLOAD)(state)
|
||||||
);
|
);
|
||||||
if (notify) {
|
if (notify && currentPage !== 'subscriptions') {
|
||||||
dispatch(
|
dispatch(
|
||||||
setSubscriptionNotification(
|
setSubscriptionNotification(
|
||||||
savedSubscription,
|
savedSubscription,
|
||||||
|
|
Loading…
Reference in a new issue