Add watched/unwatched information to Playlists and Collection pages

This commit is contained in:
HighImKevin committed 2026-03-14 14:21:04 -04:00
1 parent f8a033a407
commit be6037c8cd
2 files changed
+55 -1

No files matched your search

+30 -1
View File
@@ -595,6 +595,34 @@
activePage.dataset.collectionSortingAdded = 'true';
}
/**
* Update collection page by adding the played item count to the page
* @param {Object} item - Collection item (BoxSet)
*/
async function updateCollectionPage(item) {
const unplayedItemCount = item.UserData?.UnplayedItemCount || 0;
const totalItemCount = item.RecursiveItemCount || item.ChildCount || 0;
const playedItemCount = totalItemCount - unplayedItemCount;
const isVideoCollection = document.querySelector('.libraryPage:not(.hide) .collectionItems:has(.card[data-mediatype="Video"])').length > 0;
const progressText = isVideoCollection ? 'watched' : 'complete';
const incompleteText = isVideoCollection ? 'unwatched' : 'incomplete';
const itemMiscInfoPrimary = document.querySelector('.libraryPage:not(.hide) .itemMiscInfo-primary');
if (itemMiscInfoPrimary && unplayedItemCount > 0) {
const mediaInfoItem = document.createElement('div');
mediaInfoItem.className = 'mediaInfoItem';
mediaInfoItem.textContent = `${playedItemCount} ${progressText}`;
itemMiscInfoPrimary.appendChild(mediaInfoItem);
const mediaInfoItemIncomplete = document.createElement('div');
mediaInfoItemIncomplete.className = 'mediaInfoItem';
mediaInfoItemIncomplete.textContent = `${unplayedItemCount} ${incompleteText}`;
itemMiscInfoPrimary.appendChild(mediaInfoItemIncomplete);
}
}
/**
* Initialize collections hook
*/
@@ -619,7 +647,8 @@
// Small delay to ensure details DOM is ready
setTimeout(async () => {
if (item && item.Id && item.Type === 'BoxSet') {
await addCollectionSorting(item);
addCollectionSorting(item);
updateCollectionPage(item);
}
}, 100);
},