From 357c3e44e195fa5f11909a510ca797059baa1021 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Sun, 8 Feb 2026 12:57:40 +0000 Subject: [PATCH 1/5] fix: support sorting algolia search results --- app/components/Package/ListToolbar.vue | 23 ++-- app/pages/search.vue | 165 ++++++++++++++++++------- i18n/locales/en.json | 1 + lunaria/files/en-GB.json | 1 + lunaria/files/en-US.json | 1 + 5 files changed, 138 insertions(+), 53 deletions(-) diff --git a/app/components/Package/ListToolbar.vue b/app/components/Package/ListToolbar.vue index ce0b2fa269..84be1a6ee2 100644 --- a/app/components/Package/ListToolbar.vue +++ b/app/components/Package/ListToolbar.vue @@ -30,6 +30,8 @@ const props = defineProps<{ activeFilters: FilterChip[] /** When true, shows search-specific UI (relevance sort, no filters) */ searchContext?: boolean + /** Sort keys to force-disable (e.g. when the current provider doesn't support them) */ + disabledSortKeys?: SortKey[] }>() const { t } = useI18n() @@ -58,17 +60,20 @@ const showingFiltered = computed(() => props.filteredCount !== props.totalCount) const currentSort = computed(() => parseSortOption(sortOption.value)) // Get available sort keys based on context +const disabledSet = computed(() => new Set(props.disabledSortKeys ?? [])) + const availableSortKeys = computed(() => { + const applyDisabled = (k: (typeof SORT_KEYS)[number]) => ({ + ...k, + disabled: k.disabled || disabledSet.value.has(k.key), + }) + if (props.searchContext) { - // In search context: show relevance (enabled) and others (disabled) - return SORT_KEYS.filter(k => !k.searchOnly || k.key === 'relevance').map(k => - Object.assign({}, k, { - disabled: k.key !== 'relevance', - }), - ) + // In search context: show relevance + non-disabled sorts (downloads, updated, name) + return SORT_KEYS.filter(k => !k.searchOnly || k.key === 'relevance').map(applyDisabled) } // In org/user context: hide search-only sorts - return SORT_KEYS.filter(k => !k.searchOnly) + return SORT_KEYS.filter(k => !k.searchOnly).map(applyDisabled) }) // Handle sort key change from dropdown @@ -182,9 +187,9 @@ function getSortKeyLabelKey(key: SortKey): string { - +