diff --git a/components/explore/ExploreChain.vue b/components/explore/ExploreChain.vue index 1640808b58..0006de10a6 100644 --- a/components/explore/ExploreChain.vue +++ b/components/explore/ExploreChain.vue @@ -33,14 +33,14 @@ const selected = computed(() => function onSwitchChain(chain) { $store.dispatch('setUrlPrefix', chain) - + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { page, ...restQuery } = route.query router.push({ params: { prefix: chain, }, query: { - ...route.query, - page: '1', + ...restQuery, }, }) } diff --git a/components/explore/ExploreSort.vue b/components/explore/ExploreSort.vue index b7817b9f06..837da774be 100644 --- a/components/explore/ExploreSort.vue +++ b/components/explore/ExploreSort.vue @@ -98,11 +98,12 @@ const selectedSort = computed({ }) function onChange(selected) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { page, ...restQuery } = route.query router.push({ path: route.fullPath, query: { - ...route.query, - page: '1', + ...restQuery, sort: removeDuplicateSortKeys(selected), }, }) diff --git a/components/search/Search.vue b/components/search/Search.vue index 6ed0bae472..1fccbbfb5f 100644 --- a/components/search/Search.vue +++ b/components/search/Search.vue @@ -310,14 +310,15 @@ export default class Search extends mixins( if (pathName && pathName !== this.$route.path) { return } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { page, ...restQuery } = this.$route.query this.$router .replace({ path: this.isExplorePage ? String(this.$route.path) : `/${this.urlPrefix}/explore/items`, query: { - page: '1', - ...this.$route.query, + ...restQuery, search: this.searchQuery || this.$route.query.search || undefined, ...queryCondition, }, diff --git a/components/search/SearchSuggestion.vue b/components/search/SearchSuggestion.vue index 68410ec6c2..eb436de457 100644 --- a/components/search/SearchSuggestion.vue +++ b/components/search/SearchSuggestion.vue @@ -303,7 +303,6 @@ export default class SearchSuggestion extends mixins(PrefixMixin) { .replace({ path: String(this.$route.path), query: { - page: '1', search: this.name, }, }) diff --git a/composables/useListInfiniteScroll.ts b/composables/useListInfiniteScroll.ts index 83f6afe33f..3069ea1bd7 100644 --- a/composables/useListInfiniteScroll.ts +++ b/composables/useListInfiniteScroll.ts @@ -95,14 +95,19 @@ export default function ({ useScroll(window, { onScroll: updateCurrentPage, throttle: 1000 }) useResizeObserver(document.body, onResize) - const replaceUrlPage = (page: string) => { - if (page === route.query.page) { + const replaceUrlPage = (targetPage: string) => { + if (targetPage === route.query.page) { return } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { page, ...restQuery } = route.query router .replace({ path: String(route.path), - query: { ...route.query, page }, + query: + targetPage === '1' + ? { ...restQuery } + : { ...restQuery, page: targetPage }, }) .catch($consola.warn) } diff --git a/composables/useReplaceUrl.ts b/composables/useReplaceUrl.ts index f43d7ad4d8..379a2c9fd6 100644 --- a/composables/useReplaceUrl.ts +++ b/composables/useReplaceUrl.ts @@ -1,3 +1,5 @@ +import { remove } from 'cypress/types/lodash' + export const replaceBooleanWithStrings = ( obj: Record ): Record => { @@ -41,7 +43,7 @@ export default function ( ...replaceBooleanWithStrings(queryCondition), } if (resetPage) { - query.page = '1' + delete query.page } router .replace({