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

Fixed wallet preference page refresh #7443

Merged
merged 2 commits into from
Mar 2, 2017
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
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should try to keep the declarative naming conventions here so maybe navigatorHandlerRegistered and navigatorHandlerUnregistered?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call 👍 Since this is already merged, please feel free to do as a follow up, @NejcZdovc 😄

})
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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to the above comment, the app constant name should match the action name

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

default:
break
}
Expand Down Expand Up @@ -466,15 +471,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 @@ -754,6 +754,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 @@ -929,6 +929,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 @@ -94,7 +94,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