Show "99+" in unplayed indicator when more 100 or more new items

This commit is contained in:
Andrew Rabert 2024-05-01 18:03:20 -04:00
parent b1add6f48d
commit 10198f9056
2 changed files with 12 additions and 4 deletions

View File

@ -78,7 +78,7 @@ export function getPlayedIndicatorHtml(item) {
if (enablePlayedIndicator(item)) {
const userData = item.UserData || {};
if (userData.UnplayedItemCount) {
return '<div class="countIndicator indicator">' + datetime.toLocaleString(userData.UnplayedItemCount) + '</div>';
return '<div class="countIndicator indicator">' + formatCountIndicator(userData.UnplayedItemCount) + '</div>';
}
if (userData.PlayedPercentage && userData.PlayedPercentage >= 100 || (userData.Played)) {
@ -93,12 +93,16 @@ export function getChildCountIndicatorHtml(item, options) {
const minCount = options?.minCount ? options.minCount : 0;
if (item.ChildCount && item.ChildCount > minCount) {
return '<div class="countIndicator indicator">' + datetime.toLocaleString(item.ChildCount) + '</div>';
return '<div class="countIndicator indicator">' + formatCountIndicator(item.ChildCount) + '</div>';
}
return '';
}
function formatCountIndicator(count) {
return count >= 100 ? '99+' : count.toString();
}
export function getTimerIndicator(item) {
let status;

View File

@ -60,6 +60,10 @@ const enablePlayedIndicator = (item: ItemDto) => {
return itemHelper.canMarkPlayed(item);
};
const formatCountIndicator = (count: number) => {
return count >= 100 ? '99+' : count.toString();
};
const useIndicator = (item: ItemDto) => {
const getMediaSourceIndicator = () => {
const mediaSourceCount = item.MediaSourceCount ?? 0;
@ -135,7 +139,7 @@ const useIndicator = (item: ItemDto) => {
if (childCount > 1) {
return (
<Box className='countIndicator indicator childCountIndicator'>
{datetime.toLocaleString(item.ChildCount)}
{formatCountIndicator(childCount)}
</Box>
);
}
@ -149,7 +153,7 @@ const useIndicator = (item: ItemDto) => {
if (userData.UnplayedItemCount) {
return (
<Box className='countIndicator indicator unplayedItemCount'>
{datetime.toLocaleString(userData.UnplayedItemCount)}
{formatCountIndicator(userData.UnplayedItemCount)}
</Box>
);
}