fix: use published_at for latest/oldest sort
All checks were successful
Release to Staging / build_and_release (push) Successful in 46s

This commit is contained in:
daniyal 2024-08-27 20:46:42 +05:00
parent a5018d9a1f
commit 1259144228
3 changed files with 7 additions and 9 deletions

6
package-lock.json generated
View File

@ -3808,9 +3808,9 @@
}
},
"node_modules/micromatch": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz",
"integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==",
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true,
"dependencies": {
"braces": "^3.0.3",

View File

@ -85,7 +85,7 @@ export const ModsPage = () => {
setIsFetching(true)
const until =
mods.length > 0 ? mods[mods.length - 1].edited_at - 1 : undefined
mods.length > 0 ? mods[mods.length - 1].published_at - 1 : undefined
fetchMods(filterOptions.source, until)
.then((res) => {
@ -100,7 +100,7 @@ export const ModsPage = () => {
const handlePrev = useCallback(() => {
setIsFetching(true)
const since = mods.length > 0 ? mods[0].edited_at + 1 : undefined
const since = mods.length > 0 ? mods[0].published_at + 1 : undefined
fetchMods(filterOptions.source, undefined, since)
.then((res) => {
@ -139,9 +139,9 @@ export const ModsPage = () => {
}
if (filterOptions.sort === SortBy.Latest) {
filtered.sort((a, b) => b.edited_at - a.edited_at)
filtered.sort((a, b) => b.published_at - a.published_at)
} else if (filterOptions.sort === SortBy.Oldest) {
filtered.sort((a, b) => a.edited_at - b.edited_at)
filtered.sort((a, b) => a.published_at - b.published_at)
}
return filtered

View File

@ -167,8 +167,6 @@ export const fetchMods = async (
return RelayController.getInstance()
.fetchEvents(filter, []) // Pass the filter and an empty array of options
.then((events) => {
console.log('events :>> ', events)
// Convert the fetched events into a list of mods
const modList = constructModListFromEvents(events)
return modList // Return the list of mods