From e81f9bd59222917500a7255dcc6783544189324b Mon Sep 17 00:00:00 2001 From: Jason Sadler Date: Fri, 4 May 2018 13:47:43 -0400 Subject: [PATCH] Implemented fix to show publisher toggle for PDFs Updated publisherToggle to grab the real URL lint Renamed publisherState name to publisherUtil --- app/common/lib/publisherUtil.js | 8 ++++---- app/renderer/components/navigation/publisherToggle.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/common/lib/publisherUtil.js b/app/common/lib/publisherUtil.js index 89d1c503175..45b5a70c171 100644 --- a/app/common/lib/publisherUtil.js +++ b/app/common/lib/publisherUtil.js @@ -8,17 +8,17 @@ const settings = require('../../../js/constants/settings') // Utils const ledgerUtil = require('./ledgerUtil') const {getSetting} = require('../../../js/settings') -const {isHttpOrHttps} = require('../../../js/lib/urlutil') +const {isHttpOrHttps, getUrlFromPDFUrl} = require('../../../js/lib/urlutil') const {isSourceAboutUrl} = require('../../../js/lib/appUrlUtil') -const publisherState = { +const publisherUtil = { shouldShowAddPublisherButton: (state, location, publisherKey) => { return location && !isSourceAboutUrl(location) && getSetting(settings.PAYMENTS_ENABLED) && - isHttpOrHttps(location) && + isHttpOrHttps(getUrlFromPDFUrl(location)) && !ledgerUtil.blockedP(state, publisherKey) } } -module.exports = publisherState +module.exports = publisherUtil diff --git a/app/renderer/components/navigation/publisherToggle.js b/app/renderer/components/navigation/publisherToggle.js index 109a926ebe3..caf82308b14 100644 --- a/app/renderer/components/navigation/publisherToggle.js +++ b/app/renderer/components/navigation/publisherToggle.js @@ -18,7 +18,7 @@ const tabState = require('../../../common/state/tabState') const ledgerState = require('../../../common/state/ledgerState') // Utils -const {getHostPattern} = require('../../../../js/lib/urlutil') +const {getHostPattern, getUrlFromPDFUrl} = require('../../../../js/lib/urlutil') const {getBaseUrl} = require('../../../../js/lib/appUrlUtil') const frameStateUtil = require('../../../../js/state/frameStateUtil') const ledgerUtil = require('../../../common/lib/ledgerUtil') @@ -107,7 +107,7 @@ class PublisherToggle extends React.Component { const currentWindow = state.get('currentWindow') const activeFrame = frameStateUtil.getActiveFrame(currentWindow) || Immutable.Map() const tabId = activeFrame.get('tabId', tabState.TAB_ID_NONE) - const location = activeFrame.get('location', '') + const location = getUrlFromPDFUrl(activeFrame.get('location', '')) const locationId = getBaseUrl(location) const publisherKey = ledgerState.getVerifiedPublisherLocation(state, locationId)