diff --git a/pkg/app/post_routes.go b/pkg/app/post_routes.go index 48a0d9d..4844267 100644 --- a/pkg/app/post_routes.go +++ b/pkg/app/post_routes.go @@ -62,7 +62,7 @@ func postGet(c *gin.Context) { } c.JSON(http.StatusOK, models.PostPaginationResponse{ CurrentPage: page, - TotalPage: postPages, + PostCount: postPages, Posts: postResult, }) } diff --git a/pkg/models/responses.go b/pkg/models/responses.go index f0c2956..816bb64 100644 --- a/pkg/models/responses.go +++ b/pkg/models/responses.go @@ -20,6 +20,6 @@ type BlobResponse struct { type PostPaginationResponse struct { CurrentPage int `json:"currentPage"` - TotalPage int `json:"totalPage"` + PostCount int `json:"postCount"` Posts []PostListItem `json:"posts"` } diff --git a/pkg/services/post.go b/pkg/services/post.go index f8cc855..f004f19 100644 --- a/pkg/services/post.go +++ b/pkg/services/post.go @@ -2,7 +2,6 @@ package services import ( "log" - "math" "github.com/Damillora/Shioriko/pkg/database" "github.com/Damillora/Shioriko/pkg/models" @@ -83,7 +82,7 @@ func UpdatePost(id string, model models.PostUpdateModel) (*database.Post, error) func CountPostPages() int { var count int64 database.DB.Model(&database.Post{}).Count(&count) - return int(math.Abs(float64(count-1))/perPage) + 1 + return int(count) } func CountPostPagesTag(tagSyntax []string) int { tags, err := ParseReadTags(tagSyntax) @@ -93,8 +92,7 @@ func CountPostPagesTag(tagSyntax []string) int { var count int64 count = database.DB.Model(&tags).Distinct().Joins("Blob").Preload("Tags").Preload("Tags.TagType").Association("Posts").Count() - - return int(math.Abs(float64(count-1))/perPage) + 1 + return int(count) } func DeletePost(id string) error { diff --git a/web/app/package.json b/web/app/package.json index 9870613..bf60052 100644 --- a/web/app/package.json +++ b/web/app/package.json @@ -24,6 +24,7 @@ "postcss": "^8.2.14", "query-string": "^7.0.0", "sirv-cli": "^1.0.0", + "svelte-infinite-scroll": "^1.5.2", "svelte-preprocess": "^4.7.3", "svelte-routing": "^1.6.0", "svelte-tags-input": "^2.7.1" diff --git a/web/app/src/PostPaginator.svelte b/web/app/src/PostPaginator.svelte deleted file mode 100644 index 6c37e64..0000000 --- a/web/app/src/PostPaginator.svelte +++ /dev/null @@ -1,119 +0,0 @@ - - - -
- {#each postChunks as postChunk} -
- {#each postChunk as post, i (post.id)} -
-
-
- - {post.id} - -
-
-
- {#if post.tags} - {#each post.tags as tag (tag)} - - {/each} - {:else} - None - {/if} -
-
- {/each} -
- {/each} -
diff --git a/web/app/src/routes/Posts.svelte b/web/app/src/routes/Posts.svelte index 01b422a..60b4a18 100644 --- a/web/app/src/routes/Posts.svelte +++ b/web/app/src/routes/Posts.svelte @@ -1,52 +1,62 @@