From afd0111b94e0762bb346f9095999b7cae48cb80b Mon Sep 17 00:00:00 2001 From: AJ Date: Tue, 3 Oct 2023 11:52:50 -0400 Subject: [PATCH 1/8] Added condition to display concatenated text if artist count is over 10. Fixed #4228 --- src/controllers/itemDetails/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/controllers/itemDetails/index.js b/src/controllers/itemDetails/index.js index 99dbd8d2ea5..78584f7a92f 100644 --- a/src/controllers/itemDetails/index.js +++ b/src/controllers/itemDetails/index.js @@ -441,8 +441,20 @@ function renderName(item, container, context) { if (parentNameHtml.length) { if (parentNameLast) { // Music + // Determine if there are over 10 artists in the album. If so, concat with 'and X others.' + const artists = parentNameHtml[0].split(' / '); + const otherArtistCount = artists.length - 10; + let newParentNameHtml = artists.slice(0, 10).join(' / '); + newParentNameHtml = `${newParentNameHtml} and ${otherArtistCount} other artists.
`; + if (layoutManager.mobile) { - html = '

' + parentNameHtml.join('
') + '

'; + if (artists.length > 10) { + html = '

' + newParentNameHtml + '

'; + } else { + html = '

' + parentNameHtml.join('
') + '

'; + } + } else if (artists.length > 10) { + html = '

' + newParentNameHtml + '

'; } else { html = '

' + parentNameHtml.join(' - ') + '

'; } From 74866bebc0202233d88d787175a18d15ef49fecc Mon Sep 17 00:00:00 2001 From: AJ Date: Wed, 4 Oct 2023 09:06:19 -0400 Subject: [PATCH 2/8] Added string to strings.json. Used globalize.translate() --- src/controllers/itemDetails/index.js | 2 +- src/strings/en-us.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/itemDetails/index.js b/src/controllers/itemDetails/index.js index 78584f7a92f..d41a04eee16 100644 --- a/src/controllers/itemDetails/index.js +++ b/src/controllers/itemDetails/index.js @@ -445,7 +445,7 @@ function renderName(item, container, context) { const artists = parentNameHtml[0].split(' / '); const otherArtistCount = artists.length - 10; let newParentNameHtml = artists.slice(0, 10).join(' / '); - newParentNameHtml = `${newParentNameHtml} and ${otherArtistCount} other artists.
`; + newParentNameHtml = `${newParentNameHtml} ${globalize.translate('AndOtherArtists', otherArtistCount)}
`; if (layoutManager.mobile) { if (artists.length > 10) { diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 12023468eb2..f5790425a86 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -46,6 +46,7 @@ "AllowTonemappingHelp": "Tone-mapping can transform the dynamic range of a video from HDR to SDR while maintaining image details and colors, which are very important information for representing the original scene. Currently works only with 10bit HDR10, HLG and DoVi videos. This requires the corresponding GPGPU runtime.", "AlwaysPlaySubtitles": "Always Play", "AlwaysPlaySubtitlesHelp": "Subtitles matching the language preference will be loaded regardless of the audio language.", + "AndOtherArtists": "and {0} other artists.", "AnyLanguage": "Any Language", "Anytime": "Anytime", "ApiKeysCaption": "List of the currently enabled API keys", From 4a5a8fc656fc9f2d83a046d1afb700f4b2c49d10 Mon Sep 17 00:00:00 2001 From: AJ Date: Wed, 18 Oct 2023 16:53:48 -0400 Subject: [PATCH 3/8] Moved code to getArtistLinksHtml function --- src/controllers/itemDetails/index.js | 43 +++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/controllers/itemDetails/index.js b/src/controllers/itemDetails/index.js index d41a04eee16..eaaa0cf857e 100644 --- a/src/controllers/itemDetails/index.js +++ b/src/controllers/itemDetails/index.js @@ -386,14 +386,29 @@ function reloadUserDataButtons(page, item) { function getArtistLinksHtml(artists, serverId, context) { const html = []; + const numberOfArtists = artists.length; - for (const artist of artists) { - const href = appRouter.getRouteUrl(artist, { - context: context, - itemType: 'MusicArtist', - serverId: serverId - }); - html.push('' + escapeHtml(artist.Name) + ''); + if (numberOfArtists < 10) { + for (const artist of artists) { + const href = appRouter.getRouteUrl(artist, { + context: context, + itemType: 'MusicArtist', + serverId: serverId + }); + html.push('' + escapeHtml(artist.Name) + ''); + } + } else { + for (let i = 0; i < 10; i++) { + const artist = artists[i]; + const href = appRouter.getRouteUrl(artist, { + context: context, + itemType: 'MusicArtist', + serverId: serverId + }); + html.push('' + escapeHtml(artist.Name) + ''); + } + const remainingNumberOfArtists = numberOfArtists - 10; + html.push(`${globalize.translate('AndOtherArtists', remainingNumberOfArtists)}`); } return html.join(' / '); @@ -441,20 +456,8 @@ function renderName(item, container, context) { if (parentNameHtml.length) { if (parentNameLast) { // Music - // Determine if there are over 10 artists in the album. If so, concat with 'and X others.' - const artists = parentNameHtml[0].split(' / '); - const otherArtistCount = artists.length - 10; - let newParentNameHtml = artists.slice(0, 10).join(' / '); - newParentNameHtml = `${newParentNameHtml} ${globalize.translate('AndOtherArtists', otherArtistCount)}
`; - if (layoutManager.mobile) { - if (artists.length > 10) { - html = '

' + newParentNameHtml + '

'; - } else { - html = '

' + parentNameHtml.join('
') + '

'; - } - } else if (artists.length > 10) { - html = '

' + newParentNameHtml + '

'; + html = '

' + parentNameHtml.join('
') + '

'; } else { html = '

' + parentNameHtml.join(' - ') + '

'; } From 5777d225bb0c1a27b64e1a261b712901b4f1676e Mon Sep 17 00:00:00 2001 From: alfred-delacosta <132242610+alfred-delacosta@users.noreply.github.com> Date: Fri, 20 Oct 2023 22:10:45 -0400 Subject: [PATCH 4/8] Update src/controllers/itemDetails/index.js Co-authored-by: Bill Thornton --- src/controllers/itemDetails/index.js | 30 ++++++++++------------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/controllers/itemDetails/index.js b/src/controllers/itemDetails/index.js index eaaa0cf857e..7d27566b797 100644 --- a/src/controllers/itemDetails/index.js +++ b/src/controllers/itemDetails/index.js @@ -388,25 +388,17 @@ function getArtistLinksHtml(artists, serverId, context) { const html = []; const numberOfArtists = artists.length; - if (numberOfArtists < 10) { - for (const artist of artists) { - const href = appRouter.getRouteUrl(artist, { - context: context, - itemType: 'MusicArtist', - serverId: serverId - }); - html.push('' + escapeHtml(artist.Name) + ''); - } - } else { - for (let i = 0; i < 10; i++) { - const artist = artists[i]; - const href = appRouter.getRouteUrl(artist, { - context: context, - itemType: 'MusicArtist', - serverId: serverId - }); - html.push('' + escapeHtml(artist.Name) + ''); - } + for (let i = 0; i < Math.min(numberOfArtists, 10); i++) { + const artist = artists[i]; + const href = appRouter.getRouteUrl(artist, { + context, + itemType: 'MusicArtist', + serverId + }); + html.push('' + escapeHtml(artist.Name) + ''); + } + + if (numberOfArtists > 10) { const remainingNumberOfArtists = numberOfArtists - 10; html.push(`${globalize.translate('AndOtherArtists', remainingNumberOfArtists)}`); } From 2a2043f88af2c134ff8f66b7025fe51ec2a0f124 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Tue, 24 Oct 2023 15:29:06 -0400 Subject: [PATCH 5/8] Simplify appending other artists string --- src/controllers/itemDetails/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/controllers/itemDetails/index.js b/src/controllers/itemDetails/index.js index 7d27566b797..359c8932deb 100644 --- a/src/controllers/itemDetails/index.js +++ b/src/controllers/itemDetails/index.js @@ -399,8 +399,7 @@ function getArtistLinksHtml(artists, serverId, context) { } if (numberOfArtists > 10) { - const remainingNumberOfArtists = numberOfArtists - 10; - html.push(`${globalize.translate('AndOtherArtists', remainingNumberOfArtists)}`); + html.push(globalize.translate('AndOtherArtists', numberOfArtists - 10)); } return html.join(' / '); From ed219a777d91bd53addc7bf6ced46d5e05d6a62e Mon Sep 17 00:00:00 2001 From: alfred-delacosta <132242610+alfred-delacosta@users.noreply.github.com> Date: Thu, 30 Nov 2023 09:57:18 -0500 Subject: [PATCH 6/8] Update src/controllers/itemDetails/index.js Co-authored-by: Bill Thornton --- src/controllers/itemDetails/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/controllers/itemDetails/index.js b/src/controllers/itemDetails/index.js index 359c8932deb..6d53b56f235 100644 --- a/src/controllers/itemDetails/index.js +++ b/src/controllers/itemDetails/index.js @@ -398,11 +398,13 @@ function getArtistLinksHtml(artists, serverId, context) { html.push('' + escapeHtml(artist.Name) + ''); } + let fullHtml = html.join(' / '); + if (numberOfArtists > 10) { - html.push(globalize.translate('AndOtherArtists', numberOfArtists - 10)); + fullHtml += globalize.translate('AndOtherArtists', numberOfArtists - 10); } - return html.join(' / '); + return fullHtml; } /** From 3f0770e7df445fb4792ae78bdf37480afc1317d1 Mon Sep 17 00:00:00 2001 From: alfred-delacosta <132242610+alfred-delacosta@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:09:57 -0400 Subject: [PATCH 7/8] Update src/controllers/itemDetails/index.js Co-authored-by: felix920506 --- src/controllers/itemDetails/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/itemDetails/index.js b/src/controllers/itemDetails/index.js index 6d53b56f235..584452e6bd8 100644 --- a/src/controllers/itemDetails/index.js +++ b/src/controllers/itemDetails/index.js @@ -401,7 +401,7 @@ function getArtistLinksHtml(artists, serverId, context) { let fullHtml = html.join(' / '); if (numberOfArtists > 10) { - fullHtml += globalize.translate('AndOtherArtists', numberOfArtists - 10); + fullHtml = globalize.translate('AndOtherArtists', fullHtml, numberOfArtists - 10); } return fullHtml; From 1a6a44293605666ff1eca9487605d2d0c71a3830 Mon Sep 17 00:00:00 2001 From: alfred-delacosta <132242610+alfred-delacosta@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:10:08 -0400 Subject: [PATCH 8/8] Update src/strings/en-us.json Co-authored-by: felix920506 --- src/strings/en-us.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strings/en-us.json b/src/strings/en-us.json index f5790425a86..56b6c4f673e 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -46,7 +46,7 @@ "AllowTonemappingHelp": "Tone-mapping can transform the dynamic range of a video from HDR to SDR while maintaining image details and colors, which are very important information for representing the original scene. Currently works only with 10bit HDR10, HLG and DoVi videos. This requires the corresponding GPGPU runtime.", "AlwaysPlaySubtitles": "Always Play", "AlwaysPlaySubtitlesHelp": "Subtitles matching the language preference will be loaded regardless of the audio language.", - "AndOtherArtists": "and {0} other artists.", + "AndOtherArtists": "{0} and {1} other artists.", "AnyLanguage": "Any Language", "Anytime": "Anytime", "ApiKeysCaption": "List of the currently enabled API keys",