sorted history yay

This commit is contained in:
AntoninoP 2024-09-06 19:25:05 +02:00
parent 0a0b5a7020
commit 89477505aa

View File

@ -53,8 +53,13 @@ const ServerHistory = () => {
return parsedEntry;
});
const sortedHistoryArray = historyArray.sort((a, b) => {
const dateA = new Date(a.timestamp);
const dateB = new Date(b.timestamp);
return dateB - dateA;
});
setHistory(historyArray);
setHistory(sortedHistoryArray);
} else {
console.error("Failed to fetch history, response:", response);
}
@ -66,6 +71,7 @@ const ServerHistory = () => {
}
};
useEffect(() => {
fetchServerHistory();
}, [serverName]);