From ab74cc77c340123b69f9a6fad7c8b3292689febd Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Mon, 25 Apr 2016 21:05:21 +0200 Subject: [PATCH] Prevent users from querying playlists while fetching data --- src/public/components/duplicate-finder-box.js | 12 +++++++----- src/public/components/playlist-box.js | 16 +++++++++++++--- src/public/index.html | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/public/components/duplicate-finder-box.js b/src/public/components/duplicate-finder-box.js index 7daa80d..071ee4a 100644 --- a/src/public/components/duplicate-finder-box.js +++ b/src/public/components/duplicate-finder-box.js @@ -13,7 +13,8 @@ var DuplicateFinderBox = React.createClass({ currentUId: null, dups: null, dupsLoading: false, - clicked: false + clicked: false, + title: null }; }, componentWillReceiveProps: function () { @@ -21,12 +22,13 @@ var DuplicateFinderBox = React.createClass({ clicked: false }); }, - handlePlaylistClick: function (id, uid) { + handlePlaylistClick: function (id, uid, title) { this.setState({ currentId: id, currentUId: uid, dupsLoading: true, - clicked: true + clicked: true, + title: title }); var self = this; @@ -59,7 +61,7 @@ var DuplicateFinderBox = React.createClass({ } duplicates = ( -

Duplicates

+

Duplicates in {this.state.title}

{duplicates} ) @@ -67,7 +69,7 @@ var DuplicateFinderBox = React.createClass({ var playlistBox =

Loading...

; if (!this.props.playlistsLoading) { - playlistBox = ; + playlistBox = ; } return ( diff --git a/src/public/components/playlist-box.js b/src/public/components/playlist-box.js index 4fe0fe9..2da1498 100644 --- a/src/public/components/playlist-box.js +++ b/src/public/components/playlist-box.js @@ -10,8 +10,10 @@ var PlaylistBox = React.createClass({ }, clickOnItem: function (id, uid, event) { event.preventDefault(); - this.setState({currentId: id}); - this.props.handleClick(id, uid); + if (!this.props.dupsLoading) { + this.setState({currentId: id}); + this.props.handleClick(id, uid); + } }, render: function () { var ListGroup = ReactBootstrap.ListGroup, @@ -22,8 +24,16 @@ var PlaylistBox = React.createClass({ if (this.props.playlists) { playlists = this.props.playlists.map(function (pl) { var id = pl.id; + var active = currentId == id; + var classes = this.props.dupsLoading ? "disabled" : ""; return ( - {pl.name} + + {pl.name} + ); }, this); } diff --git a/src/public/index.html b/src/public/index.html index 059f4a0..12ffd29 100644 --- a/src/public/index.html +++ b/src/public/index.html @@ -2,7 +2,7 @@ DAVIDS • DuplicAtes VIewer and Detector for Spotify - +