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