contribution sort control in sidebar
This commit is contained in:
@@ -829,11 +829,20 @@ function updateContributionsList() {
|
||||
return matchesCategory && matchesSearch;
|
||||
});
|
||||
|
||||
// Sorts by Date (newest first)
|
||||
// Sorts by selected Option
|
||||
var sortBy = document.getElementById('list-sort') ? document.getElementById('list-sort').value : 'date-desc';
|
||||
filtered.sort(function (a, b) {
|
||||
return new Date(b.properties.created_at) - new Date(a.properties.created_at);
|
||||
if (sortBy === 'date-desc') return new Date(b.properties.created_at) - new Date(a.properties.created_at);
|
||||
if (sortBy === 'date-asc') return new Date(a.properties.created_at) - new Date(b.properties.created_at);
|
||||
if (sortBy === 'likes') return b.properties.likes_count - a.properties.likes_count;
|
||||
if (sortBy === 'comments') return (b.properties.comment_count || 0) - (a.properties.comment_count || 0);
|
||||
return 0;
|
||||
});
|
||||
|
||||
// Updates Count Display
|
||||
var countEl = document.getElementById('list-count');
|
||||
if (countEl) countEl.textContent = filtered.length + ' Beiträge';
|
||||
|
||||
// Builds HTML
|
||||
if (filtered.length === 0) {
|
||||
container.innerHTML = '<p class="empty-state">Keine Beiträge gefunden.</p>';
|
||||
|
||||
Reference in New Issue
Block a user