From 8fd06823f2c764c7e1a9ca4479c5905da1da8dbb Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Sun, 5 Feb 2017 20:14:27 +1300 Subject: [PATCH] Scroll to top on route; Notifications click behind --- src/js/index.js | 5 +++-- src/js/services/spotify/actions.js | 2 ++ src/js/services/spotify/middleware.js | 4 ++++ src/scss/components/_notifications.scss | 4 +++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/js/index.js b/src/js/index.js index d80f10db..d1911ad4 100755 --- a/src/js/index.js +++ b/src/js/index.js @@ -39,16 +39,17 @@ import LibraryLocalDirectory from './views/library/LibraryLocalDirectory' // setup our analytics tracking ReactGA.initialize('UA-64701652-3'); -function logPageView() { +function handleUpdate() { ReactGA.set({ page: window.location.hash }) ReactGA.pageview(window.location.hash) + $(window).scrollTop(0) } global.baseURL = '/' ReactDOM.render( - + diff --git a/src/js/services/spotify/actions.js b/src/js/services/spotify/actions.js index 85a78b30..cd7c02f1 100755 --- a/src/js/services/spotify/actions.js +++ b/src/js/services/spotify/actions.js @@ -1,4 +1,5 @@ +var uiActions = require('../../services/ui/actions.js') var helpers = require('../../helpers.js') /** @@ -39,6 +40,7 @@ const sendRequest = ( dispatch, getState, endpoint, method = 'GET', data = false }, (xhr, status, error) => { console.error( endpoint+' failed', xhr.responseText) + dispatch(uiActions.createNotification(xhr.responseText,'bad')) reject(error) } ) diff --git a/src/js/services/spotify/middleware.js b/src/js/services/spotify/middleware.js index 6aca393c..d9a88b1a 100755 --- a/src/js/services/spotify/middleware.js +++ b/src/js/services/spotify/middleware.js @@ -17,6 +17,10 @@ const SpotifyMiddleware = (function(){ store.dispatch( spotifyActions.getMe() ) break + case 'SPOTIFY_DISCONNECTED': + store.dispatch( uiActions.createNotification('Spotify disconnected','bad') ) + break + case 'SPOTIFY_CREATE_PLAYLIST': if( !store.getState().spotify.authorized ){ store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) ) diff --git a/src/scss/components/_notifications.scss b/src/scss/components/_notifications.scss index fe413312..15d310a2 100755 --- a/src/scss/components/_notifications.scss +++ b/src/scss/components/_notifications.scss @@ -6,7 +6,8 @@ left: 0; right: 0; text-align: center; - z-index: 100; + z-index: 99; + pointer-events: none; .notification { display: inline-block; @@ -15,6 +16,7 @@ padding: 12px 32px 12px 18px; margin: 0 0.5px; color: #FFFFFF; + pointer-events: all; &:first-child { border-top-left-radius: 50px;