You've already forked AstralRinth
forked from didirus/AstralRinth
App fixes 0.9.0 (#3034)
* push fixes to test on windows * Fix searching mods * Fix search not saving, fix scrolling issues, etc
This commit is contained in:
@@ -21,7 +21,6 @@ import { useRoute, useRouter } from 'vue-router'
|
||||
import SearchCard from '@/components/ui/SearchCard.vue'
|
||||
import { get as getInstance, get_projects as getInstanceProjects } from '@/helpers/profile.js'
|
||||
import { get_search_results } from '@/helpers/cache.js'
|
||||
import { debounce } from '@/helpers/utils.js'
|
||||
import NavTabs from '@/components/ui/NavTabs.vue'
|
||||
import type Instance from '@/components/ui/Instance.vue'
|
||||
import InstanceIndicator from '@/components/ui/InstanceIndicator.vue'
|
||||
@@ -190,6 +189,7 @@ const pageCount = computed(() =>
|
||||
)
|
||||
|
||||
watch(requestParams, () => {
|
||||
if (!route.params.projectType) return
|
||||
refreshSearch()
|
||||
})
|
||||
|
||||
@@ -214,45 +214,40 @@ async function refreshSearch() {
|
||||
}
|
||||
}
|
||||
results.value = rawResults.result
|
||||
|
||||
const persistentParams: LocationQuery = {}
|
||||
|
||||
for (const [key, value] of Object.entries(route.query)) {
|
||||
if (PERSISTENT_QUERY_PARAMS.includes(key)) {
|
||||
persistentParams[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
if (instanceHideInstalled.value) {
|
||||
persistentParams.ai = 'true'
|
||||
} else {
|
||||
delete persistentParams.ai
|
||||
}
|
||||
|
||||
const params = {
|
||||
...persistentParams,
|
||||
...createPageParams(),
|
||||
}
|
||||
|
||||
breadcrumbs.setContext({
|
||||
name: 'Discover content',
|
||||
link: `/browse/${projectType.value}`,
|
||||
query: params,
|
||||
})
|
||||
await router.replace({ path: route.path, query: params })
|
||||
}
|
||||
|
||||
function setPage(newPageNumber: number) {
|
||||
async function setPage(newPageNumber: number) {
|
||||
currentPage.value = newPageNumber
|
||||
|
||||
updateSearchResults()
|
||||
onSearchChangeToTop()
|
||||
await onSearchChangeToTop()
|
||||
}
|
||||
|
||||
async function updateSearchResults() {
|
||||
await refreshSearch()
|
||||
|
||||
if (import.meta.client) {
|
||||
const persistentParams: LocationQuery = {}
|
||||
|
||||
for (const [key, value] of Object.entries(route.query)) {
|
||||
if (PERSISTENT_QUERY_PARAMS.includes(key)) {
|
||||
persistentParams[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
if (instanceHideInstalled.value) {
|
||||
persistentParams.ai = 'true'
|
||||
} else {
|
||||
delete persistentParams.ai
|
||||
}
|
||||
|
||||
const params = {
|
||||
...persistentParams,
|
||||
...createPageParams(),
|
||||
}
|
||||
|
||||
await router.replace({ path: route.path, query: params })
|
||||
breadcrumbs.setContext({ name: 'Discover content', link: route.path, query: params })
|
||||
}
|
||||
}
|
||||
|
||||
const debouncedSearchChange = debounce(() => updateSearchResults(1), 200)
|
||||
|
||||
const searchWrapper: Ref<HTMLElement | null> = ref(null)
|
||||
|
||||
async function onSearchChangeToTop() {
|
||||
@@ -261,13 +256,10 @@ async function onSearchChangeToTop() {
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
}
|
||||
|
||||
async function clearSearch() {
|
||||
function clearSearch() {
|
||||
query.value = ''
|
||||
await updateSearchResults()
|
||||
}
|
||||
|
||||
async function clearFilters() {}
|
||||
|
||||
watch(
|
||||
() => route.params.projectType,
|
||||
async (newType) => {
|
||||
@@ -275,14 +267,9 @@ watch(
|
||||
if (!newType || newType === projectType.value) return
|
||||
|
||||
projectType.value = newType
|
||||
breadcrumbs.setContext({ name: 'Discover content', link: `/browse/${projectType.value}` })
|
||||
|
||||
currentSortType.value = { display: 'Relevance', name: 'relevance' }
|
||||
query.value = ''
|
||||
|
||||
loading.value = true
|
||||
await clearFilters()
|
||||
loading.value = false
|
||||
},
|
||||
)
|
||||
|
||||
@@ -418,7 +405,6 @@ await refreshSearch()
|
||||
spellcheck="false"
|
||||
type="text"
|
||||
:placeholder="`Search ${projectType}s...`"
|
||||
@input="debouncedSearchChange()"
|
||||
/>
|
||||
<Button v-if="query" class="r-btn" @click="() => clearSearch()">
|
||||
<XIcon />
|
||||
@@ -432,7 +418,6 @@ await refreshSearch()
|
||||
name="Sort by"
|
||||
:options="sortTypes as any"
|
||||
:display-name="(option: SortType | undefined) => option?.display"
|
||||
@change="updateSearchResults()"
|
||||
>
|
||||
<span class="font-semibold text-primary">Sort by: </span>
|
||||
<span class="font-semibold text-secondary">{{ selected }}</span>
|
||||
@@ -443,7 +428,6 @@ await refreshSearch()
|
||||
name="Max results"
|
||||
:options="[5, 10, 15, 20, 50, 100]"
|
||||
class="max-w-[9rem]"
|
||||
@change="updateSearchResults()"
|
||||
>
|
||||
<span class="font-semibold text-primary">View: </span>
|
||||
<span class="font-semibold text-secondary">{{ selected }}</span>
|
||||
|
||||
Reference in New Issue
Block a user