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 #12351 from brave/fix/12345
Browse files Browse the repository at this point in the history
Add falsey checks for frames and closed frames
  • Loading branch information
NejcZdovc committed Dec 22, 2017
1 parent 8379ff3 commit e6fc6b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ function tabTemplateInit (frameProps) {
const template = [CommonMenu.newTabMenuItem(frameProps.get('tabId'))]
const location = frameProps.get('location')
const store = windowStore.getState()
const frames = store.get('frames')
const closedFrames = store.get('closedFrames')

if (location !== 'about:newtab') {
template.push(
Expand All @@ -454,7 +456,7 @@ function tabTemplateInit (frameProps) {
})
}

if (windowStore.getState().get('frames').size > 1 &&
if (frames && frames.size > 1 &&
!frameProps.get('pinnedLocation')) {
template.push({
label: locale.translation('detach'),
Expand Down Expand Up @@ -486,7 +488,6 @@ function tabTemplateInit (frameProps) {
// }
// })

const frames = windowStore.getState().get('frames')
const frameToSkip = frameProps.get('key')
const frameList = frames.map((frame) => {
return {
Expand Down Expand Up @@ -551,7 +552,7 @@ function tabTemplateInit (frameProps) {

template.push(Object.assign({},
CommonMenu.reopenLastClosedTabItem(),
{ enabled: store.get('closedFrames').size > 0 }
{ enabled: closedFrames ? closedFrames.size > 0 : false }
))

return menuUtil.sanitizeTemplateItems(template)
Expand Down
2 changes: 1 addition & 1 deletion js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ const doAction = (action) => {
case windowConstants.WINDOW_UNDO_CLOSED_FRAME:
{
const closedFrames = windowState.get('closedFrames')
if (closedFrames.size === 0) {
if (!closedFrames || closedFrames.size === 0) {
break
}
const frame = closedFrames.last()
Expand Down

0 comments on commit e6fc6b0

Please sign in to comment.