Merge pull request #39 from hubHarmony/SortedHistory

sorted history yay
This commit is contained in:
Antoninop 2024-09-06 19:33:25 +02:00 committed by GitHub
commit 4ec70e510e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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]);