Skip to content

Commit 034e4ab

Browse files
committed
add DEFAULT_SORT const
1 parent f34bac3 commit 034e4ab

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

app/pages/org/[org].vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ definePageMeta({
1010
const route = useRoute('org')
1111
const router = useRouter()
1212
13+
const DEFAULT_SORT = 'downloads-week-desc' satisfies SortOption
14+
1315
const orgName = computed(() => route.params.org.toLowerCase())
1416
1517
const { isConnected } = useConnector()
@@ -57,7 +59,7 @@ const {
5759
setSort,
5860
} = useStructuredFilters({
5961
packages,
60-
initialSort: (normalizeSearchParam(route.query.sort) as SortOption) ?? 'downloads-week-desc',
62+
initialSort: (normalizeSearchParam(route.query.sort) as SortOption) ?? DEFAULT_SORT,
6163
})
6264
6365
// Pagination state
@@ -86,7 +88,7 @@ const updateUrl = debounce((updates: { filter?: string; sort?: string }) => {
8688
query: {
8789
...route.query,
8890
q: updates.filter || undefined,
89-
sort: updates.sort && updates.sort !== 'downloads-week-desc' ? updates.sort : undefined,
91+
sort: updates.sort && updates.sort !== DEFAULT_SORT ? updates.sort : undefined,
9092
},
9193
})
9294
}, 300)
@@ -112,7 +114,7 @@ const totalWeeklyDownloads = computed(() =>
112114
// Reset state when org changes
113115
watch(orgName, () => {
114116
clearAllFilters()
115-
setSort('downloads-week-desc')
117+
setSort(DEFAULT_SORT)
116118
currentPage.value = 1
117119
})
118120

0 commit comments

Comments
 (0)