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

Commit

Permalink
fixes #1717
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed May 19, 2016
1 parent 09877a6 commit 656746a
Showing 1 changed file with 20 additions and 44 deletions.
64 changes: 20 additions & 44 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,23 @@ class Frame extends ImmutableComponent {
}

componentDidMount () {
this.updateWebview()
const cb = () => {
this.webview.setZoomLevel(this.zoomLevel)
this.webview.setAudioMuted(this.props.frame.get('audioMuted') || false)
this.updateAboutDetails({})
}
this.updateWebview(cb)
}

get zoomLevel () {
const location = this.props.frame.get('location')
const settings = this.props.frame.get('isPrivate')
? siteSettings.getSiteSettingsForURL(this.props.temporarySiteSettings, location)
: siteSettings.getSiteSettingsForURL(this.props.siteSettings, location)
if (!settings || !settings.get('zoomLevel')) {
return config.zoom.defaultValue
}
return settings.get('zoomLevel')
}

zoom (stepSize) {
Expand Down Expand Up @@ -179,11 +195,13 @@ class Frame extends ImmutableComponent {

componentDidUpdate (prevProps, prevState) {
const cb = () => {
this.handleShortcut()
this.webview.setZoomLevel(this.zoomLevel)
// give focus when switching tabs
if (this.props.isActive && !prevProps.isActive) {
this.webview.focus()
}
this.handleShortcut()
this.webview.setAudioMuted(this.props.frame.get('audioMuted') || false)
this.updateAboutDetails(prevProps)
}

Expand Down Expand Up @@ -393,10 +411,6 @@ class Frame extends ImmutableComponent {
this.props.frame,
this.webview.canGoBack(),
this.webview.canGoForward())
if (this.zoomLevel !== config.zoom.defaultValue) {
// Timeout to work around setting zoom too early not working in Electron
this.webview.setZoomLevel(this.zoomLevel)
}
}
const loadEnd = () => {
windowActions.onWebviewLoadEnd(
Expand Down Expand Up @@ -506,12 +520,6 @@ class Frame extends ImmutableComponent {
}
})

// Ensure we mute appropriately, the initial value could be set
// from persisted state.
if (this.props.frame.get('audioMuted')) {
this.webview.setAudioMuted(true)
}

// Handle zoom using Ctrl/Cmd and the mouse wheel.
this.webview.addEventListener('mousewheel', this.onMouseWheel.bind(this))
}
Expand Down Expand Up @@ -588,38 +596,6 @@ class Frame extends ImmutableComponent {
this.webview.stopFindInPage('clearSelection')
}

componentWillReceiveProps (nextProps) {
if (nextProps.frame.get('audioMuted') &&
this.props.frame.get('audioMuted') !== true) {
this.webview.setAudioMuted(true)
} else if (!nextProps.frame.get('audioMuted') &&
this.props.frame.get('audioMuted') === true) {
this.webview.setAudioMuted(false)
}

const nextLocation = nextProps.frame.get('location')
const nextSiteSettings = this.props.frame.get('isPrivate')
? siteSettings.getSiteSettingsForURL(nextProps.temporarySiteSettings, nextLocation)
: siteSettings.getSiteSettingsForURL(nextProps.siteSettings, nextLocation)
if (nextSiteSettings) {
const nextZoom = nextSiteSettings.get('zoomLevel')
if (this.zoomLevel !== nextZoom) {
this.webview.setZoomLevel(nextZoom)
}
}
}

get zoomLevel () {
const location = this.props.frame.get('location')
const settings = this.props.frame.get('isPrivate')
? siteSettings.getSiteSettingsForURL(this.props.temporarySiteSettings, location)
: siteSettings.getSiteSettingsForURL(this.props.siteSettings, location)
if (!settings) {
return config.zoom.defaultValue
}
return settings.get('zoomLevel')
}

render () {
return <div
className={cx({
Expand Down

1 comment on commit 656746a

@bbondy
Copy link
Member

@bbondy bbondy commented on 656746a May 20, 2016

Choose a reason for hiding this comment

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

++ pls use summary titles though so it can be read without having to click on the fix link.
And put fix link in the body. Thanks.

Please sign in to comment.