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

Implemented fix to show publisher toggle for PDFs #14028

Merged
merged 1 commit into from
May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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