Merge pull request #1912 from lbryio/fix-subscription-notification

don't show notification for new subscription if on subscription page
This commit is contained in:
Sean Yesmunt 2018-08-28 11:33:54 -04:00 committed by GitHub
commit 2038a49256
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,7 +7,7 @@ import type { Dispatch, SubscriptionNotifications } from 'redux/reducers/subscri
import type { Subscription } from 'types/subscription';
import { selectSubscriptions } from 'redux/selectors/subscriptions';
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 { doClaimRewardType } from 'redux/actions/rewards';
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>
const state = getState();
const currentPage = selectCurrentPage(state);
const savedSubscription = state.subscriptions.subscriptions.find(
sub => sub.uri === subscriptionUri
);
@ -141,6 +142,11 @@ export const doCheckSubscription = (subscriptionUri: string, notify?: boolean) =
const claimResult = result[subscriptionUri] || {};
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(
claim => `${claim.name}#${claim.claim_id}` === savedSubscription.latest
);
@ -158,7 +164,7 @@ export const doCheckSubscription = (subscriptionUri: string, notify?: boolean) =
!claim.value.stream.metadata.fee &&
makeSelectClientSetting(SETTINGS.AUTO_DOWNLOAD)(state)
);
if (notify) {
if (notify && currentPage !== 'subscriptions') {
dispatch(
setSubscriptionNotification(
savedSubscription,