Shuffle posts randomly on each page load

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-08 15:07:31 +02:00
parent d24c4e5acb
commit 4285bb0d40

View File

@@ -217,10 +217,19 @@ function renderCommentsList(comments) {
// =========================== // ===========================
// RENDER CARDS // RENDER CARDS
// =========================== // ===========================
function shuffleArray(arr) {
for (let i = arr.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}
return arr;
}
function renderCards() { function renderCards() {
const grid = document.getElementById('postGrid'); const grid = document.getElementById('postGrid');
if (!grid) return; if (!grid) return;
shuffleArray(APP.posts);
grid.innerHTML = APP.posts.map(p => { grid.innerHTML = APP.posts.map(p => {
const liked = APP.userLikes.includes(p.id); const liked = APP.userLikes.includes(p.id);
const likeCount = APP.likes[p.id] || 0; const likeCount = APP.likes[p.id] || 0;