Adding page titles
This commit is contained in:
@ -1,6 +1,14 @@
|
||||
|
||||
import * as helpers from '../../helpers'
|
||||
|
||||
export function setWindowTitle(title = null, play_state = null){
|
||||
return {
|
||||
type: 'SET_WINDOW_TITLE',
|
||||
title: title,
|
||||
play_state: play_state
|
||||
}
|
||||
}
|
||||
|
||||
export function setSelectedTracks(keys = []){
|
||||
if (typeof(keys) === 'string'){
|
||||
keys = [keys]
|
||||
|
||||
@ -22,11 +22,36 @@ const UIMiddleware = (function(){
|
||||
if (tracks[current_track_uri] !== undefined){
|
||||
current_track = tracks[current_track_uri];
|
||||
}
|
||||
|
||||
helpers.setWindowTitle(current_track, action.data);
|
||||
next(action);
|
||||
break
|
||||
|
||||
case 'SET_WINDOW_TITLE':
|
||||
|
||||
var window_title = "";
|
||||
|
||||
if (action.play_state){
|
||||
var play_state = action.play_state;
|
||||
} else {
|
||||
var play_state = store.getState().mopidy.play_state;
|
||||
}
|
||||
|
||||
if (play_state == 'playing'){
|
||||
window_title = '\u25B6';
|
||||
} else {
|
||||
window_title = '\u25A0';
|
||||
}
|
||||
|
||||
if (action.title){
|
||||
var title = action.title;
|
||||
} else {
|
||||
var title = store.getState().ui.window_title;
|
||||
}
|
||||
|
||||
document.title = window_title+' '+title;
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'OPEN_MODAL':
|
||||
if (store.getState().ui.allow_reporting){
|
||||
ReactGA.event({ category: 'Modal', action: 'Opened', label: action.modal.name });
|
||||
|
||||
@ -14,9 +14,15 @@ export default function reducer(ui = {}, action){
|
||||
return Object.assign({}, ui, { debug_response: action.response })
|
||||
|
||||
case 'UI_SET':
|
||||
console.log(action);
|
||||
return Object.assign({}, ui, action.data);
|
||||
|
||||
case 'SET_WINDOW_TITLE':
|
||||
if (action.title){
|
||||
return Object.assign({}, ui, { window_title: action.title });
|
||||
} else {
|
||||
return ui;
|
||||
}
|
||||
|
||||
case 'TOGGLE_SIDEBAR':
|
||||
var new_state = !ui.sidebar_open
|
||||
if (typeof(action.new_state) !== 'undefined' ) new_state = action.new_state
|
||||
|
||||
Reference in New Issue
Block a user