You've already forked AstralRinth
forked from didirus/AstralRinth
Creator update hotfixes (#1531)
* Put image upload on v3 * Fix space encoding in search * Add safety to any iterables
This commit is contained in:
@@ -31,7 +31,8 @@ export const useImageUpload = async (file: File, ctx: ImageUploadContext) => {
|
|||||||
const response = (await useBaseFetch(url, {
|
const response = (await useBaseFetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: file,
|
body: file,
|
||||||
})) as ImageUploadResponse // TODO: zod or object validation
|
apiVersion: 3,
|
||||||
|
})) as ImageUploadResponse
|
||||||
|
|
||||||
// Type check to see if response has a url property and an id property
|
// Type check to see if response has a url property and an id property
|
||||||
if (!response?.id || typeof response.id !== 'string') {
|
if (!response?.id || typeof response.id !== 'string') {
|
||||||
|
|||||||
@@ -159,9 +159,9 @@
|
|||||||
<LibraryIcon class="primary-stat__icon" aria-hidden="true" />
|
<LibraryIcon class="primary-stat__icon" aria-hidden="true" />
|
||||||
<div v-if="projects" class="primary-stat__text">
|
<div v-if="projects" class="primary-stat__text">
|
||||||
<span class="primary-stat__counter">
|
<span class="primary-stat__counter">
|
||||||
{{ $formatNumber(projects.length || 0) }}
|
{{ $formatNumber(projects?.length || 0) }}
|
||||||
</span>
|
</span>
|
||||||
project<span v-if="projects.length !== 1">s</span>
|
project<span v-if="projects?.length !== 1">s</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="projects && projects.length > 0"
|
v-if="projects && projects?.length > 0"
|
||||||
:class="
|
:class="
|
||||||
'project-list display-mode--' + (cosmetics.searchDisplayMode.collection || 'list')
|
'project-list display-mode--' + (cosmetics.searchDisplayMode.collection || 'list')
|
||||||
"
|
"
|
||||||
@@ -454,15 +454,11 @@ const canEdit = computed(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const projectTypes = computed(() => {
|
const projectTypes = computed(() => {
|
||||||
const obj = {}
|
const projectSet = new Set(
|
||||||
|
projects.value?.map((project) => project?.project_type).filter((x) => x !== undefined) || []
|
||||||
for (const project of projects.value) {
|
)
|
||||||
obj[project.project_type] = true
|
projectSet.delete('project')
|
||||||
}
|
return Array.from(projectSet)
|
||||||
|
|
||||||
delete obj.project
|
|
||||||
|
|
||||||
return Object.keys(obj)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const icon = ref(null)
|
const icon = ref(null)
|
||||||
@@ -483,19 +479,16 @@ async function saveChanges() {
|
|||||||
apiVersion: 3,
|
apiVersion: 3,
|
||||||
})
|
})
|
||||||
} else if (icon.value) {
|
} else if (icon.value) {
|
||||||
await useBaseFetch(
|
const ext = icon.value?.type?.split('/').pop()
|
||||||
`collection/${collection.value.id}/icon?ext=${
|
if (!ext) throw new Error('Invalid file type')
|
||||||
icon.value.type.split('/')[icon.value.type.split('/').length - 1]
|
await useBaseFetch(`collection/${collection.value.id}/icon?ext=${ext}`, {
|
||||||
}`,
|
method: 'PATCH',
|
||||||
{
|
body: icon.value,
|
||||||
method: 'PATCH',
|
apiVersion: 3,
|
||||||
body: icon.value,
|
})
|
||||||
apiVersion: 3,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const projectsToRemove = removeProjects.value.map((p) => p.id)
|
const projectsToRemove = removeProjects.value?.map((p) => p.id) ?? []
|
||||||
const newProjects = projects.value
|
const newProjects = projects.value
|
||||||
.filter((p) => !projectsToRemove.includes(p.id))
|
.filter((p) => !projectsToRemove.includes(p.id))
|
||||||
.map((p) => p.id)
|
.map((p) => p.id)
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ const {
|
|||||||
const params = [`limit=${maxResults.value}`, `index=${sortType.value.name}`]
|
const params = [`limit=${maxResults.value}`, `index=${sortType.value.name}`]
|
||||||
|
|
||||||
if (query.value.length > 0) {
|
if (query.value.length > 0) {
|
||||||
params.push(`query=${encodeURIComponent(query.value.replace(/ /g, '+'))}`)
|
params.push(`query=${encodeURIComponent(query.value)}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user