diff --git a/src/js/services/genius/actions.js b/src/js/services/genius/actions.js index 022bfeea..826d3e7d 100755 --- a/src/js/services/genius/actions.js +++ b/src/js/services/genius/actions.js @@ -152,8 +152,7 @@ export function getTrackLyrics(uri, path) { return (dispatch, getState) => { dispatch(coreActions.itemLoaded({ uri, - lyrics: null, - lyrics_path: null, + lyrics: undefined, })); const url = `//${getState().mopidy.host}:${getState().mopidy.port}/iris/http/get_lyrics?path=${path}&connection_id=${getState().pusher.connection_id}`; @@ -181,23 +180,24 @@ export function getTrackLyrics(uri, path) { .then((data) => { if (data.result) { const html = $(data.result); - let lyrics = html.find('.lyrics'); - if (lyrics.length > 0) { - lyrics = lyrics.first(); - lyrics.find('a').replaceWith((k, v) => v); + // Give the JS thread a moment to render the complex page (lots of JS within it) + setTimeout(() => { + let lyrics = html.find('div[class^="Lyrics__Container"], div.lyrics'); + if (lyrics.length > 0) { + lyrics = lyrics.first(); + lyrics.find('a').replaceWith((k, v) => v); - let lyrics_html = lyrics.html(); - lyrics_html = lyrics_html.replace(/(\[)/g, '['); - lyrics_html = lyrics_html.replace(/(\])/g, ']'); + let lyrics_html = lyrics.html(); + lyrics_html = lyrics_html.replace(/(\[)/g, '['); + lyrics_html = lyrics_html.replace(/(\])/g, ']'); - // console.debug(lyrics_html); - - dispatch(coreActions.itemLoaded({ - uri, - lyrics: lyrics_html, - lyrics_path: path, - })); - } + dispatch(coreActions.itemLoaded({ + uri, + lyrics: lyrics_html, + lyrics_path: path, + })); + } + }, 500); } else { dispatch(coreActions.handleException( 'Could not get track lyrics', diff --git a/src/js/views/modals/KioskMode.js b/src/js/views/modals/KioskMode.js index 926f90e4..7aed4de7 100755 --- a/src/js/views/modals/KioskMode.js +++ b/src/js/views/modals/KioskMode.js @@ -1,6 +1,5 @@ -import React from 'react'; -import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; +import React, { useState, useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; import Link from '../../components/Link'; import Modal from './Modal'; import Thumbnail from '../../components/Thumbnail'; @@ -13,10 +12,14 @@ import * as mopidyActions from '../../services/mopidy/actions'; import * as geniusActions from '../../services/genius/actions'; import { isLoading } from '../../util/helpers'; import { i18n, I18n } from '../../locale'; +import { makeItemSelector } from '../../util/selectors'; -const LyricsScroller = ({ content = '', time_position = 1, duration = 100 }) => { +const LyricsScroller = ({ + content = '', + time_position = 1, + duration = 100, +}) => { const percent = ((time_position / duration) * 110).toFixed(4); - return (