Skip to content

Commit

Permalink
temporary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thesuzerain committed Aug 2, 2023
1 parent 840c076 commit 2cef095
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions theseus_gui/src/pages/Browse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,35 +139,37 @@ if (route.query.o) {
async function refreshSearch() {
const base = 'https://api.modrinth.com/v2/'
console.log('refreshing search')
const params = [`limit=${maxResults.value}`, `index=${sortType.value.name}`]
console.log('params', params)
if (query.value.length > 0) {
params.push(`query=${query.value.replace(/ /g, '+')}`)
}
console.log('params 2')
if (instanceContext.value) {
if (!ignoreInstanceLoaders.value && projectType.value === 'mod') {
orFacets.value = [`categories:${encodeURIComponent(instanceContext.value.metadata.loader)}`]
}
console.log('params 3')
if (!ignoreInstanceGameVersions.value) {
selectedVersions.value = [instanceContext.value.metadata.game_version]
}
}
console.log('refreshing search 2')
if (
facets.value.length > 0 ||
orFacets.value.length > 0 ||
selectedVersions.value.length > 0 ||
selectedEnvironments.value.length > 0 ||
projectType.value
) {
console.log('refreshing search 3')
let formattedFacets = []
for (const facet of facets.value) {
formattedFacets.push([facet])
}
console.log('refreshing search 4')
// loaders specifier
if (orFacets.value.length > 0) {
formattedFacets.push(orFacets.value)
Expand All @@ -186,14 +188,14 @@ async function refreshSearch() {
}
formattedFacets.push(versionFacets)
}
console.log('refreshing search 5')
if (onlyOpenSource.value) {
formattedFacets.push(['open_source:true'])
}
if (selectedEnvironments.value.length > 0) {
let environmentFacets = []
console.log('refreshing search 6')
const includesClient = selectedEnvironments.value.includes('client')
const includesServer = selectedEnvironments.value.includes('server')
if (includesClient && includesServer) {
Expand All @@ -212,6 +214,7 @@ async function refreshSearch() {
]
}
}
console.log('refreshing search 7')
formattedFacets = [...formattedFacets, ...environmentFacets]
}
Expand All @@ -224,30 +227,33 @@ async function refreshSearch() {
params.push(`facets=${JSON.stringify(formattedFacets)}`)
}
console.log('refreshing search 8')
const offset = (currentPage.value - 1) * maxResults.value
if (currentPage.value !== 1) {
params.push(`offset=${offset}`)
}
console.log('refreshing search 9')
let url = 'search'
if (params.length > 0) {
for (let i = 0; i < params.length; i++) {
url += i === 0 ? `?${params[i]}` : `&${params[i]}`
}
}
console.log('refreshing search 10')
let val = `${base}${url}`
const rawResults = await useFetch(val, 'search results')
console.log('refreshing search 11')
if (instanceContext.value) {
for (let val of rawResults.hits) {
console.log('refreshing search 12')
val.installed = await check_installed(instanceContext.value.path, val.project_id).then(
(x) => (val.installed = x)
)
}
}
console.log('refreshing search 13')
results.value = rawResults
}
Expand Down

0 comments on commit 2cef095

Please sign in to comment.