From a57c207e60967615ce18b527d8d3e03002d724b7 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 28 Aug 2018 00:19:26 -0400 Subject: [PATCH] don't show notification for new subscription if on subscription page --- src/renderer/redux/actions/subscriptions.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/renderer/redux/actions/subscriptions.js b/src/renderer/redux/actions/subscriptions.js index d677d51a6..2b13840e2 100644 --- a/src/renderer/redux/actions/subscriptions.js +++ b/src/renderer/redux/actions/subscriptions.js @@ -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 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, -- 2.45.2