diff --git a/client/signup/steps/dss/index.jsx b/client/signup/steps/dss/index.jsx index 3d4215c3278552..e9fc79abdfbb32 100644 --- a/client/signup/steps/dss/index.jsx +++ b/client/signup/steps/dss/index.jsx @@ -51,13 +51,13 @@ export default React.createClass( { componentWillMount() { ThemePreviewStore.on( 'change', this.updateMarkup ); - DSSImageStore.on( 'change', this.updateScreenshot ); + DSSImageStore.on( 'change', this.updateScreenshots ); this.loadThemePreviews(); }, componentWillUnmount() { ThemePreviewStore.off( 'change', this.updateMarkup ); - DSSImageStore.off( 'change', this.updateScreenshot ); + DSSImageStore.off( 'change', this.updateScreenshots ); }, componentWillReceiveProps() { @@ -73,13 +73,14 @@ export default React.createClass( { this.setState( { markupAndStyles: ThemePreviewStore.get() } ); }, - updateScreenshot() { + updateScreenshots() { const { isLoading, lastKey, imageResultsByKey } = DSSImageStore.get(); + // If there is no search currently happening or no results for a current search... if ( ! imageResultsByKey[ lastKey ] ) { return this.setState( { isLoading, renderComplete: false, dssImage: null } ); } const dssImage = imageResultsByKey[ lastKey ]; - this.setState( { isLoading, dssImage } ); + this.setState( { isLoading, dssImage, renderComplete: false } ); }, dssImageLoaded() { @@ -100,7 +101,9 @@ export default React.createClass( { }, renderImageLoader() { - debug( 'preloading image', this.state.dssImage.url ); + if ( ! this.state.renderComplete ) { + debug( 'preloading image', this.state.dssImage.url ); + } const placeholder =