Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added max content on waterfall and moderation #231

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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