From a30d8046cc0a11915c39b5bbc450a35cee9d821e Mon Sep 17 00:00:00 2001 From: Borewit Date: Wed, 15 Aug 2018 21:45:48 +0200 Subject: [PATCH 1/6] Fix issue track number not displayed if total number of tracks is not defined (common.track.of === null). --- src/renderer/pages/player-page.js | 35 +++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 7fb8114420..401a3fa0fe 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -204,6 +204,24 @@ function renderOverlay (state) { ) } +/** + * Render track or disk number string + * @param key should be either 'track' or 'disk' + * @param label should be either 'Track' or 'Disk' + */ +function renderTrack (common, key, label) { + // Audio metadata: track-number + if (common[key].no) { + let str = `${common[key].no}` + if (common[key].of) { + str += ` of ${common[key].of}` + } + return React.createElement('div', { key, className: 'audio-' + key }, + React.createElement('label', null, label), str + ) + } +} + function renderAudioMetadata (state) { const fileSummary = state.getPlayingFileSummary() if (!fileSummary.audioInfo) return @@ -269,15 +287,14 @@ function renderAudioMetadata (state) { )) } - // Audio metadata: track-number - if (common.track && common.track.no && common.track.of) { - const track = common.track.no + ' of ' + common.track.of - elems.push(( -
- {track} -
- )) - } + // Audio metadata: disk & track-number + const count = ['track'] + count.forEach(key => { + const nrElem = renderTrack(common, key, key[0].toUpperCase() + key.substring(1)) + if (nrElem) { + elems.push(nrElem) + } + }) // Audio metadata: format const format = [] From c2594f500d216a206e7f6c0d8cf8de9d4e2bcef6 Mon Sep 17 00:00:00 2001 From: Borewit Date: Wed, 15 Aug 2018 21:46:12 +0200 Subject: [PATCH 2/6] Add disk number in addition to track number. --- src/renderer/pages/player-page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 401a3fa0fe..3817938d07 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -288,7 +288,7 @@ function renderAudioMetadata (state) { } // Audio metadata: disk & track-number - const count = ['track'] + const count = ['track', 'disk'] count.forEach(key => { const nrElem = renderTrack(common, key, key[0].toUpperCase() + key.substring(1)) if (nrElem) { From c7f30df542abda4066bc38194a3cd17dbe123527 Mon Sep 17 00:00:00 2001 From: Borewit Date: Wed, 15 Aug 2018 21:48:27 +0200 Subject: [PATCH 3/6] Update order of audio properties from: album, track, disk, format to track, disk, album, format --- src/renderer/pages/player-page.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 3817938d07..b300506ee8 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -245,6 +245,15 @@ function renderAudioMetadata (state) { )) } + // Audio metadata: disk & track-number + const count = ['track', 'disk'] + count.forEach(key => { + const nrElem = renderTrack(common, key, key[0].toUpperCase() + key.substring(1)) + if (nrElem) { + elems.push(nrElem) + } + }) + // Audio metadata: album if (common.album) { elems.push(( @@ -287,15 +296,6 @@ function renderAudioMetadata (state) { )) } - // Audio metadata: disk & track-number - const count = ['track', 'disk'] - count.forEach(key => { - const nrElem = renderTrack(common, key, key[0].toUpperCase() + key.substring(1)) - if (nrElem) { - elems.push(nrElem) - } - }) - // Audio metadata: format const format = [] fileSummary.audioInfo.format = fileSummary.audioInfo.format || '' From e2448ca74040ab6f235101f3859914509d442d00 Mon Sep 17 00:00:00 2001 From: Borewit Date: Sat, 18 Aug 2018 20:45:51 +0200 Subject: [PATCH 4/6] Return JSX block. --- src/renderer/pages/player-page.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index b300506ee8..e289a11a28 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -216,8 +216,11 @@ function renderTrack (common, key, label) { if (common[key].of) { str += ` of ${common[key].of}` } - return React.createElement('div', { key, className: 'audio-' + key }, - React.createElement('label', null, label), str + const style = { textTransform: 'capitalize' } + return ( +
+ {str} +
) } } From 43065699852bd1652c0bf90ce76567294d21cfad Mon Sep 17 00:00:00 2001 From: Borewit Date: Sun, 19 Aug 2018 09:49:31 +0200 Subject: [PATCH 5/6] Get rid of third parameter which is replaced by CSS capitalize --- src/renderer/pages/player-page.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index e289a11a28..b9c7871353 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -206,10 +206,11 @@ function renderOverlay (state) { /** * Render track or disk number string + * @param common metadata.common part * @param key should be either 'track' or 'disk' - * @param label should be either 'Track' or 'Disk' + * @return track or disk number metadata as JSX block */ -function renderTrack (common, key, label) { +function renderTrack (common, key) { // Audio metadata: track-number if (common[key].no) { let str = `${common[key].no}` @@ -251,7 +252,7 @@ function renderAudioMetadata (state) { // Audio metadata: disk & track-number const count = ['track', 'disk'] count.forEach(key => { - const nrElem = renderTrack(common, key, key[0].toUpperCase() + key.substring(1)) + const nrElem = renderTrack(common, key) if (nrElem) { elems.push(nrElem) } From 8e9184084dc1ffbec45b273b71a92816018bbb00 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Sun, 19 Aug 2018 09:50:21 -0300 Subject: [PATCH 6/6] Fixed error when value is undefined. --- src/renderer/pages/player-page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index b9c7871353..23713b0df1 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -212,7 +212,7 @@ function renderOverlay (state) { */ function renderTrack (common, key) { // Audio metadata: track-number - if (common[key].no) { + if (common[key] && common[key].no) { let str = `${common[key].no}` if (common[key].of) { str += ` of ${common[key].of}`