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

Commit

Permalink
Allow cloned tab of non active tabs
Browse files Browse the repository at this point in the history
Auditors: @bridiver

This falls into the same code as the active frame clone which has tests

Fix #2787
  • Loading branch information
bbondy committed Aug 1, 2016
1 parent 011ed74 commit f6f28d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions js/constants/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const messages = {
SHORTCUT_UNDO_CLOSED_FRAME: _,
SHORTCUT_FRAME_MUTE: _,
SHORTCUT_FRAME_RELOAD: _, /** @arg {number} key of frame */
SHORTCUT_FRAME_CLONE: _, /** @arg {number} key of frame, @arg {object} options such as openInForeground */
SHORTCUT_NEXT_TAB: _,
SHORTCUT_PREV_TAB: _,
// Misc application events
Expand Down
14 changes: 7 additions & 7 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function usernameTemplateInit (usernames, origin, action) {
}

function tabTemplateInit (frameProps) {
const tabKey = frameProps.get('key')
const frameKey = frameProps.get('key')
const items = []
items.push(
CommonMenu.newTabMenuItem(),
Expand All @@ -362,14 +362,14 @@ function tabTemplateInit (frameProps) {
label: locale.translation('reloadTab'),
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.webContents.send(messages.SHORTCUT_FRAME_RELOAD, tabKey)
focusedWindow.webContents.send(messages.SHORTCUT_FRAME_RELOAD, frameKey)
}
}
}, {
label: locale.translation('clone'),
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.webContents.send(messages.SHORTCUT_ACTIVE_FRAME_CLONE, {
focusedWindow.webContents.send(messages.SHORTCUT_FRAME_CLONE, frameKey, {
openInForeground: true
})
}
Expand Down Expand Up @@ -425,7 +425,7 @@ function tabTemplateInit (frameProps) {
click: (item, focusedWindow) => {
if (focusedWindow) {
// TODO: Don't switch active tabs when this is called
focusedWindow.webContents.send(messages.SHORTCUT_CLOSE_FRAME, tabKey)
focusedWindow.webContents.send(messages.SHORTCUT_CLOSE_FRAME, frameKey)
}
}
})
Expand All @@ -435,21 +435,21 @@ function tabTemplateInit (frameProps) {
label: locale.translation('closeOtherTabs'),
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.webContents.send(messages.SHORTCUT_CLOSE_OTHER_FRAMES, tabKey, true, true)
focusedWindow.webContents.send(messages.SHORTCUT_CLOSE_OTHER_FRAMES, frameKey, true, true)
}
}
}, {
label: locale.translation('closeTabsToRight'),
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.webContents.send(messages.SHORTCUT_CLOSE_OTHER_FRAMES, tabKey, true, false)
focusedWindow.webContents.send(messages.SHORTCUT_CLOSE_OTHER_FRAMES, frameKey, true, false)
}
}
}, {
label: locale.translation('closeTabsToLeft'),
click: (item, focusedWindow) => {
if (focusedWindow) {
focusedWindow.webContents.send(messages.SHORTCUT_CLOSE_OTHER_FRAMES, tabKey, false, true)
focusedWindow.webContents.send(messages.SHORTCUT_CLOSE_OTHER_FRAMES, frameKey, false, true)
}
}
}, CommonMenu.separatorMenuItem)
Expand Down
6 changes: 3 additions & 3 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,12 +658,12 @@ frameShortcuts.forEach((shortcut) => {
emitChanges()
})
// Listen for actions on frame N
if (['reload', 'mute'].includes(shortcut)) {
ipc.on(`shortcut-frame-${shortcut}`, (e, i) => {
if (['reload', 'mute', 'clone'].includes(shortcut)) {
ipc.on(`shortcut-frame-${shortcut}`, (e, i, args) => {
const path = ['frames', FrameStateUtil.findIndexForFrameKey(windowState.get('frames'), i)]
windowState = windowState.mergeIn(path, {
activeShortcut: shortcut,
activeShortcutDetails: null
activeShortcutDetails: args
})
emitChanges()
})
Expand Down

0 comments on commit f6f28d6

Please sign in to comment.