Skip to content

Commit

Permalink
fix: post listing
Browse files Browse the repository at this point in the history
  • Loading branch information
Chicken committed Oct 18, 2024
1 parent 2f5b03b commit 2dbd7ed
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utils/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function list(arg1?: number, arg2?: number): Promise<PostsListResult> {

posts.sort((a, b) => new Date(b.datetime).getTime() - new Date(a.datetime).getTime());
if (arg2 === undefined && arg1 !== undefined) { // list(count)
posts = posts.slice(-arg1);
posts = posts.slice(0, arg1);
} else if (arg1 && arg2) { // list(start, end)
posts = posts.slice(arg1, arg2 + 1);
}
Expand Down Expand Up @@ -124,7 +124,7 @@ async function listFromIndex(arg1?: number, arg2?: number): Promise<PostsListRes

if (arg2 === undefined && arg1 !== undefined) { // list(count)
posts = posts.slice(-arg1);
} else if (arg1 && arg2) { // list(start, end)
} else if (arg1 !== undefined && arg2 !== undefined) { // list(start, end)
posts = posts.slice(arg1, arg2 + 1);
}
return {
Expand Down Expand Up @@ -189,4 +189,4 @@ const posts = {
getPostDetails
}

export default posts
export default posts

0 comments on commit 2dbd7ed

Please sign in to comment.