Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Fix pagination #1181

Merged
merged 1 commit into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions components/ui/Pagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default {
pages() {
let pages = []

if (this.count > 4) {
if (this.count > 7) {
if (this.page + 3 >= this.count) {
pages = [
1,
Expand All @@ -93,7 +93,7 @@ export default {
this.count - 1,
this.count,
]
} else if (this.page > 4) {
} else if (this.page > 5) {
pages = [1, '-', this.page - 1, this.page, this.page + 1, '-', this.count]
} else {
pages = [1, 2, 3, 4, 5, '-', this.count]
Expand All @@ -108,6 +108,9 @@ export default {
methods: {
switchPage(newPage) {
this.$emit('switch-page', newPage)
if (newPage !== null && newPage !== '' && !isNaN(newPage)) {
this.$emit('switch-page', Math.min(Math.max(newPage, 1), this.count))
}
},
},
}
Expand Down
1 change: 0 additions & 1 deletion pages/[type]/[id]/changelog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ const filteredVersions = computed(() => {
const selectedLoaders = getArrayOrString(route.query.l) ?? []
const selectedVersionTypes = getArrayOrString(route.query.c) ?? []

currentPage.value = 1
return props.versions.filter(
(projectVersion) =>
(selectedGameVersions.length === 0 ||
Expand Down
1 change: 0 additions & 1 deletion pages/[type]/[id]/versions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ const filteredVersions = computed(() => {
const selectedLoaders = getArrayOrString(route.query.l) ?? []
const selectedVersionTypes = getArrayOrString(route.query.c) ?? []

currentPage.value = 1
return props.versions.filter(
(projectVersion) =>
(selectedGameVersions.length === 0 ||
Expand Down