Dynamic favicon (POC)

This commit is contained in:
James Barnsley
2019-04-22 21:39:40 +12:00
parent 4cae019e17
commit 4c0dbeffb3
13 changed files with 67 additions and 28 deletions

View File

@ -144,6 +144,28 @@ export let toJSON = function(data){
}
/**
* Set the app's favicon to a specific image.
*
* @param file String
* @return Boolean
*/
export let setFavicon = function(favicon){
console.log(favicon);
let link = document.createElement('link'),
oldLink = document.getElementById('favicon');
link.id = 'favicon';
link.rel = 'shortcut icon';
link.href = "/iris/assets/"+favicon;
if (oldLink) {
document.head.removeChild(oldLink);
}
document.head.appendChild(link);
}
/**
* Check if an image URL is cached or not
* Useful for bypassing load animations for cached assets (eg parallax)

View File

@ -261,13 +261,6 @@ const PusherMiddleware = (function(){
setTimeout(() => {
store.dispatch(pusherActions.connect())
}, 5000);
if (e.code !== 3001) {
store.dispatch(coreActions.handleException(
'Pusher websocket connection error',
e
));
};
};
socket.onerror = (e) => {

View File

@ -1,9 +1,9 @@
import ReactGA from 'react-ga'
import ReactGA from 'react-ga';
import * as helpers from '../../helpers';
var uiActions = require('./actions.js')
var mopidyActions = require('../mopidy/actions.js')
var helpers = require('../../helpers.js')
const UIMiddleware = (function(){
@ -36,9 +36,13 @@ const UIMiddleware = (function(){
}
if (play_state == 'playing'){
window_title = '\u25B6';
helpers.setFavicon('favicon.png');
} else {
window_title = '\u25A0';
helpers.setFavicon('favicon_paused.png');
}
if (!store.getState().mopidy.connected){
helpers.setFavicon('favicon_error.png');
}
if (action.title){