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 #7443 from NejcZdovc/hotfix/#6770-refresh
Browse files Browse the repository at this point in the history
Fixed wallet preference page refresh
  • Loading branch information
bsclifton authored Mar 2, 2017
2 parents 259b5a4 + 24273c2 commit 84e45bd
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 15 deletions.
15 changes: 14 additions & 1 deletion app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,24 @@ function initForPartition (partition) {
registerForDownloadListener,
registerForMagnetHandler]
let options = {}

if (isSessionPartition(partition)) {
options.parent_partition = ''
}

let ses = session.fromPartition(partition, options)
fns.forEach((fn) => { fn(ses, partition, module.exports.isPrivate(partition)) })
fns.forEach((fn) => {
fn(ses, partition, module.exports.isPrivate(partition))
})
ses.on('register-navigator-handler', (e, protocol, location) => {
appActions.navigatorHandler(ses.partition, protocol, location, true)
})
ses.on('unregister-navigator-handler', (e, protocol, location) => {
appActions.navigatorHandler(ses.partition, protocol, location, false)
})
ses.protocol.getNavigatorHandlers().forEach((handler) => {
appActions.navigatorHandler(ses.partition, handler.protocol, handler.location, true)
})
}

const filterableProtocols = ['http:', 'https:', 'ws:', 'wss:']
Expand Down
14 changes: 5 additions & 9 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ const doAction = (action) => {
setTimeout(networkConnected, 1 * msecs.second)
break

case appConstants.APP_NAVIGATOR_HANDLER_UPDATE:
ledgerInfo.hasBitcoinHandler = (action.register && action.protocol === 'bitcoin')
appActions.updateLedgerInfo(underscore.omit(ledgerInfo, [ '_internal' ]))
break

default:
break
}
Expand Down Expand Up @@ -458,15 +463,6 @@ if (ipc) {
}
})

ipc.on(messages.CHECK_BITCOIN_HANDLER, (event, partition) => {
const protocolHandler = session.fromPartition(partition).protocol
// TODO: https://github.com/brave/browser-laptop/issues/3625
if (typeof protocolHandler.isNavigatorProtocolHandled === 'function') {
ledgerInfo.hasBitcoinHandler = protocolHandler.isNavigatorProtocolHandled('bitcoin')
appActions.updateLedgerInfo(underscore.omit(ledgerInfo, [ '_internal' ]))
}
})

ipc.on(messages.LEDGER_PUBLISHER, (event, location) => {
var ctx

Expand Down
16 changes: 16 additions & 0 deletions docs/appActions.md
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,22 @@ Update the detail object for the open alert/confirm/prompt (triggers re-render)



### navigatorHandler(partition, protocol, location, register)

Action triggered by navigation handler

**Parameters**

**partition**: `string`, session partition

**protocol**: `string`, navigator protocol

**location**: `string`, location where handler was triggered

**register**: `boolean`, true if event was registered or false if unregistered




* * *

Expand Down
17 changes: 17 additions & 0 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,23 @@ const appActions = {
tabId,
detail
})
},

/**
* Action triggered by navigation handler
* @param partition {string} session partition
* @param protocol {string} navigator protocol
* @param location {string} location where handler was triggered
* @param register {boolean} true if event was registered or false if unregistered
*/
navigatorHandler: function (partition, protocol, location, register) {
AppDispatcher.dispatch({
actionType: appConstants.APP_NAVIGATOR_HANDLER_UPDATE,
partition,
protocol,
location,
register
})
}
}

Expand Down
3 changes: 0 additions & 3 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ class Frame extends ImmutableComponent {
updateAboutDetails (prevProps) {
let location = getBaseUrl(this.props.location)
if (location === 'about:preferences' || location === 'about:contributions' || location === aboutUrls.get('about:contributions')) {
if (prevProps.partition !== this.props.partition) {
ipc.send(messages.CHECK_BITCOIN_HANDLER, this.props.partition)
}
if (!Immutable.is(prevProps.ledgerInfo, this.props.ledgerInfo) ||
!Immutable.is(prevProps.publisherInfo, this.props.publisherInfo) ||
!Immutable.is(prevProps.preferencesData, this.props.preferencesData)) {
Expand Down
3 changes: 2 additions & 1 deletion js/constants/appConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ const appConstants = {
APP_ADD_NOSCRIPT_EXCEPTIONS: _,
APP_TAB_MESSAGE_BOX_SHOWN: _,
APP_TAB_MESSAGE_BOX_DISMISSED: _,
APP_TAB_MESSAGE_BOX_UPDATED: _
APP_TAB_MESSAGE_BOX_UPDATED: _,
APP_NAVIGATOR_HANDLER_UPDATE: _
}

module.exports = mapValuesByKeys(appConstants)
2 changes: 1 addition & 1 deletion test/unit/app/renderer/components/messageBoxTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('MessageBox component unit tests', function () {
/>
)
const instance = wrapper.instance()
assert.deepEqual(instance.buttons.toJS(), ['OK'])
assert.deepEqual(instance.buttons.toJS(), ['ok'])
})
})

Expand Down

0 comments on commit 84e45bd

Please sign in to comment.