-
Notifications
You must be signed in to change notification settings - Fork 974
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const appActions = require('../../js/actions/appActions') | ||
const messages = require('../..//js/constants/messages') | ||
const Immutable = require('immutable') | ||
const tabState = require('../common/state/tabState') | ||
const {app, extensions} = require('electron') | ||
const { makeImmutable } = require('../common/state/immutableUtil') | ||
|
@@ -52,14 +53,20 @@ const api = { | |
} | ||
|
||
const openerTabId = !source.isDestroyed() ? source.getId() : -1 | ||
let newTabValue = getTabValue(newTab.getId()) | ||
let index | ||
if (newTabValue && newTabValue.get('index') !== -1) { | ||
index = newTabValue.get('index') | ||
} | ||
|
||
// TODO(bridiver) - handle pinned property?? - probably through tabValue | ||
const frameOpts = { | ||
location, | ||
partition: newTab.session.partition, | ||
guestInstanceId: newTab.guestInstanceId, | ||
openerTabId, | ||
disposition | ||
disposition, | ||
index | ||
} | ||
|
||
if (disposition === 'new-window' || disposition === 'new-popup') { | ||
|
@@ -81,6 +88,9 @@ const api = { | |
tab.on('set-active', function (evt, active) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bbondy
Author
Member
|
||
updateTab(tabId) | ||
}) | ||
tab.on('set-tab-index', function (evt, index) { | ||
updateTab(tabId) | ||
}) | ||
tab.on('page-favicon-updated', function (e, favicons) { | ||
if (favicons && favicons.length > 0) { | ||
// tab.setTabValues({ | ||
|
@@ -138,10 +148,17 @@ const api = { | |
}) | ||
|
||
process.on('on-tab-created', (tab, options) => { | ||
if (tab.isDestroyed()) { | ||
return | ||
} | ||
|
||
if (options.index !== undefined) { | ||
tab.setTabValues({ | ||
This comment has been minimized.
Sorry, something went wrong.
bridiver
Collaborator
|
||
index: options.index | ||
}) | ||
} | ||
|
||
tab.once('did-attach', () => { | ||
if (tab.isDestroyed()) { | ||
return | ||
} | ||
if (options.back) { | ||
tab.goBack() | ||
} else if (options.forward) { | ||
|
@@ -173,10 +190,14 @@ const api = { | |
clone: (state, action) => { | ||
action = makeImmutable(action) | ||
const tabId = action.get('tabId') | ||
const options = action.get('options') | ||
let options = action.get('options') || Immutable.Map() | ||
let tabValue = getTabValue(tabId) | ||
if (tabValue && tabValue.get('index') !== undefined) { | ||
options = options.set('index', tabValue.get('index') + 1) | ||
} | ||
const tab = api.getWebContents(tabId) | ||
if (tab && !tab.isDestroyed()) { | ||
tab.clone(options && options.toJS() || {}, (newTab) => { | ||
tab.clone(options.toJS(), (newTab) => { | ||
}) | ||
} | ||
return state | ||
|
both of these are actually wrong (set-active and set-tab-index). In both cases the emit happens before the value is set so
updateTab
won't get the new value. I think I originally did it that way to allow the listener to call e.preventDefault, but I can't really think of a reason why we would do that