Skip to content

Commit

Permalink
Fixes brave#8540 - Added "Mute All", Fixed "Mute Other Tabs", made "(…
Browse files Browse the repository at this point in the history
…Un)Mute Tab" always present, changed Mute icon display behavior.
  • Loading branch information
philkloose committed May 2, 2017
1 parent f179a05 commit 0eab876
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
14 changes: 7 additions & 7 deletions app/renderer/components/tabs/content/audioTabIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const globalStyles = require('../../styles/global')
const tabStyles = require('../../styles/tab')

class AudioTabIcon extends ImmutableComponent {
get pageCanPlayAudio () {
get pageAudioActive () {
return !!this.props.tab.get('audioPlaybackActive')
}

Expand All @@ -24,7 +24,7 @@ class AudioTabIcon extends ImmutableComponent {
}

get mutedState () {
return this.pageCanPlayAudio && !!this.props.tab.get('audioMuted')
return !!this.props.tab.get('audioMuted')
}

get audioIcon () {
Expand All @@ -34,11 +34,11 @@ class AudioTabIcon extends ImmutableComponent {
}

render () {
return this.pageCanPlayAudio && this.shouldShowAudioIcon
? <TabIcon
className={css(tabStyles.icon, styles.audioIcon)}
symbol={this.audioIcon} onClick={this.props.onClick} />
: null
return this.mutedState || (!this.mutedState && this.pageAudioActive)
? <TabIcon
className={css(tabStyles.icon, styles.audioIcon)}
symbol={this.audioIcon} onClick={this.props.onClick} />
: null
}
}

Expand Down
29 changes: 17 additions & 12 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ function tabPageTemplateInit (framePropsList) {
}

function generateMuteFrameList (framePropsList, muted) {
return framePropsList.map((frameProp) => {
return {
frameKey: frameProp.get('key'),
tabId: frameProp.get('tabId'),
muted: muted && frameProp.get('audioPlaybackActive') && !frameProp.get('audioMuted')
}
})
}
return framePropsList.map((frameProp) => {
return {
frameKey: frameProp.get('key'),
tabId: frameProp.get('tabId'),
muted: muted
}
})
}

function urlBarTemplateInit (searchDetail, activeFrame, e) {
const items = getEditableItems(window.getSelection().toString())
Expand Down Expand Up @@ -598,16 +598,15 @@ function tabTemplateInit (frameProps) {
}
})

if (frameProps.get('audioPlaybackActive')) {
const isMuted = frameProps.get('audioMuted')
const isMuted = frameProps.get('audioMuted')

template.push({
template.push({
label: locale.translation(isMuted ? 'unmuteTab' : 'muteTab'),
click: (item) => {
windowActions.setAudioMuted(frameKey, tabId, !isMuted)
}
})
}


template.push(CommonMenu.separatorMenuItem)

Expand Down Expand Up @@ -665,6 +664,12 @@ function tabsBarTemplateInit (framePropsList) {
CommonMenu.newWindowMenuItem(),
CommonMenu.separatorMenuItem,
CommonMenu.showTabPreviewsMenuItem(),
{
label: locale.translation('muteTabs'),
click: () => {
windowActions.muteAllAudio(generateMuteFrameList(framePropsList, true))
}
},
CommonMenu.separatorMenuItem,
CommonMenu.bookmarksManagerMenuItem(),
CommonMenu.bookmarksToolbarMenuItem(),
Expand Down

0 comments on commit 0eab876

Please sign in to comment.