Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #14028 from jasonrsadler/fix/#14025-pdf-payment
Browse files Browse the repository at this point in the history
Implemented fix to show publisher toggle for PDFs
  • Loading branch information
Jason Sadler committed May 4, 2018
1 parent c176498 commit 0eef9e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions app/common/lib/publisherUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions app/renderer/components/navigation/publisherToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 0eef9e1

Please sign in to comment.