Skip to content

Commit

Permalink
Added max content on waterfall and moderation (#231)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
csharpfritz and github-actions[bot] authored Oct 10, 2023
1 parent 30e598a commit 80bc07c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/TagzApp.Web/wwwroot/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

var paused = false;
var pauseQueue = [];
const waterfallMaxEntries = 100;
const moderationMaxEntries = 500;

const taggedContent = document.getElementById('taggedContent');
const observer = new MutationObserver(function (mutationsList, observer) {
Expand Down Expand Up @@ -217,6 +219,19 @@
const index = getIndexForValue(times, newMessageTime);
taggedContent.insertBefore(newMessage, taggedContent.children[index]);
}

// Remove oldest message if we're over the max
if (
document.querySelector('.currentModerators') == null &&
taggedContent.children.length > waterfallMaxEntries
) {
taggedContent.lastElementChild.remove();
} else if (
document.querySelector('.currentModerators') != null &&
taggedContent.children.length > moderationMaxEntries
) {
taggedContent.lastElementChild.remove();
}
}

function FormatMessageForModeration(content) {
Expand Down

0 comments on commit 80bc07c

Please sign in to comment.