From f22e0251d7636111f53e7cec73f192b5d3774d2b Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Tue, 21 Mar 2017 08:33:32 +1300 Subject: [PATCH] Shortcut key notifications; Fullscreen now ctrl+fwdslash --- src/js/components/Notifications.js | 20 ++++++++++++----- src/js/services/ui/actions.js | 5 +++-- src/js/views/App.js | 30 +++++++++++++++++-------- src/js/views/Playlist.js | 3 ++- src/js/views/Queue.js | 4 ---- src/scss/components/_context-menu.scss | 2 +- src/scss/components/_notifications.scss | 17 ++++++++++++++ src/scss/global/_variables.scss | 2 ++ 8 files changed, 60 insertions(+), 23 deletions(-) diff --git a/src/js/components/Notifications.js b/src/js/components/Notifications.js index 7705514f..b4d46782 100755 --- a/src/js/components/Notifications.js +++ b/src/js/components/Notifications.js @@ -19,12 +19,20 @@ class Notifications extends React.Component{
{ this.props.notifications.map( notification => { - return ( -
- this.props.actions.removeNotification(notification.id) } /> - { notification.content } -
- ) + if (notification.is_shortcut){ + return ( +
+ +
+ ) + } else { + return ( +
+ this.props.actions.removeNotification(notification.id) } /> + { notification.content } +
+ ) + } }) }
diff --git a/src/js/services/ui/actions.js b/src/js/services/ui/actions.js index 3672f38f..d7aed541 100755 --- a/src/js/services/ui/actions.js +++ b/src/js/services/ui/actions.js @@ -222,13 +222,14 @@ export function createBrowserNotification( data ){ } } -export function createNotification( content, type = 'default' ){ +export function createNotification(content, type = 'default', is_shortcut = false){ return { type: 'CREATE_NOTIFICATION', notification: { id: helpers.generateGuid(), type: type, - content: content + content: content, + is_shortcut: is_shortcut } } } diff --git a/src/js/views/App.js b/src/js/views/App.js index 72d931d5..01b61921 100755 --- a/src/js/views/App.js +++ b/src/js/views/App.js @@ -82,7 +82,7 @@ class App extends React.Component{ shouldTriggerShortcut(e){ var ignoreNodes = ['INPUT', 'TEXTAREA']; - var keyCodes = [32,27]; + var keyCodes = [32,27,191]; if( ignoreNodes.indexOf(e.target.nodeName) > -1 ){ return false; @@ -104,19 +104,31 @@ class App extends React.Component{ switch(e.keyCode){ case 32: // spacebar - if( this.props.play_state == 'playing' ){ - this.props.mopidyActions.pause(); + if (this.props.play_state == 'playing'){ + this.props.mopidyActions.pause() + this.props.uiActions.createNotification(null, 'pause', true) }else{ - this.props.mopidyActions.play(); + this.props.mopidyActions.play() + this.props.uiActions.createNotification(null, 'play', true) } - break; + break; case 27: // esc - if( this.props.dragger && this.props.dragger.dragging ){ - this.props.uiActions.dragCancel(); + if (this.props.dragger && this.props.dragger.dragging){ + this.props.uiActions.dragCancel() } - if( this.props.modal ){ - this.props.uiActions.closeModal(); + if (this.props.modal){ + this.props.uiActions.closeModal() + } + break; + + case 191: // "/" + if (e.ctrlKey){ + if (this.props.modal){ + this.props.uiActions.closeModal() + } else { + this.props.uiActions.openModal('kiosk_mode') + } } break; } diff --git a/src/js/views/Playlist.js b/src/js/views/Playlist.js index 66cecaf1..96bfc95b 100755 --- a/src/js/views/Playlist.js +++ b/src/js/views/Playlist.js @@ -70,7 +70,8 @@ class Playlist extends React.Component{ play(){ ReactGA.event({ category: 'Playlist', action: 'Play', label: this.props.playlist.uri }) - this.props.mopidyActions.playURIs([this.props.playlist.uri], this.props.params.uri) + var track_uris = helpers.asURIs(this.props.playlist.tracks) + this.props.mopidyActions.playURIs(track_uris, this.props.params.uri) } follow(){ diff --git a/src/js/views/Queue.js b/src/js/views/Queue.js index 05021eae..b28302cd 100755 --- a/src/js/views/Queue.js +++ b/src/js/views/Queue.js @@ -63,10 +63,6 @@ class Queue extends React.Component{   Radio -