From 3ec00c864d267fb04fa5c53237f5172ab734ac1c Mon Sep 17 00:00:00 2001 From: Payton Swick Date: Thu, 3 Dec 2015 19:08:35 -0500 Subject: [PATCH] Signup: DSS: Show loading overlay during image preloading --- client/signup/steps/dss/index.jsx | 13 ++++++++----- client/signup/steps/dss/screenshot.jsx | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/client/signup/steps/dss/index.jsx b/client/signup/steps/dss/index.jsx index 3d4215c327855..e9fc79abdfbb3 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 =
; return (