Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
fix cf pages ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Jul 16, 2023
1 parent e4d8b32 commit 27f8b49
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 37 deletions.
2 changes: 1 addition & 1 deletion components/ui/report/ReportView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function fetchReport() {
let users = []
if (userIds.length > 0) {
const { data: usersVal } = await useAsyncData(`users?ids=${JSON.stringify(userIds)}`, () =>
useBaseFetch(`users?ids=${JSON.stringify(userIds)}`)
useBaseFetch(`users?ids=${encodeURIComponent(JSON.stringify(userIds))}`)
)
users = usersVal.value
}
Expand Down
8 changes: 4 additions & 4 deletions components/ui/report/ReportsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ const threadIds = [
const [{ data: users }, { data: versions }, { data: threads }] = await Promise.all([
await useAsyncData(`users?ids=${JSON.stringify(userIds)}`, () =>
useBaseFetch(`users?ids=${JSON.stringify(userIds)}`)
useBaseFetch(`users?ids=${encodeURIComponent(JSON.stringify(userIds))}`)
),
await useAsyncData(`versions?ids=${JSON.stringify(versionIds)}`, () =>
useBaseFetch(`versions?ids=${JSON.stringify(versionIds)}`)
useBaseFetch(`versions?ids=${encodeURIComponent(JSON.stringify(versionIds))}`)
),
await useAsyncData(`threads?ids=${JSON.stringify(threadIds)}`, () =>
useBaseFetch(`threads?ids=${JSON.stringify(threadIds)}`)
useBaseFetch(`threads?ids=${encodeURIComponent(JSON.stringify(threadIds))}`)
),
])
Expand All @@ -71,7 +71,7 @@ const versionProjects = versions.value.map((version) => version.project_id)
const projectIds = [...new Set(reportedProjects.concat(versionProjects))]
const { data: projects } = await useAsyncData(`projects?ids=${JSON.stringify(projectIds)}`, () =>
useBaseFetch(`projects?ids=${JSON.stringify(projectIds)}`)
useBaseFetch(`projects?ids=${encodeURIComponent(JSON.stringify(projectIds))}`)
)
reports.value = rawReports.map((report) => {
Expand Down
1 change: 1 addition & 0 deletions composables/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export const useBaseFetch = async (url, options = {}, skipAuth = false) => {
options.headers.Authorization = auth.value.token
}

console.log(`${base}${url}`)
return await $fetch(`${base}${url}`, options)
}
2 changes: 1 addition & 1 deletion helpers/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function getBulk(type, ids) {
return []
}

const url = `${type}?ids=${JSON.stringify([...new Set(ids)])}`
const url = `${type}?ids=${encodeURIComponent(JSON.stringify([...new Set(ids)]))}`
const { data: bulkFetch } = await useAsyncData(url, () => useBaseFetch(url))
return bulkFetch.value
}
Expand Down
55 changes: 24 additions & 31 deletions pages/moderation/review.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,37 +145,30 @@ const projectTypes = computed(() => {
if (projects.value) {
const teamIds = projects.value.map((x) => x.team)
await useAsyncData(
'teams?ids=' + JSON.stringify(teamIds),
() => useBaseFetch('teams?ids=' + JSON.stringify(teamIds)),
{
transform: (result) => {
if (result) {
members.value = result
projects.value = projects.value.map((project) => {
project.owner = members.value
.flat()
.find((x) => x.team_id === project.team && x.role === 'Owner').user
project.age = project.queued ? now - app.$dayjs(project.queued) : Number.MAX_VALUE
project.age_warning = ''
if (project.age > TIME_24H * 2) {
project.age_warning = 'danger'
} else if (project.age > TIME_24H) {
project.age_warning = 'warning'
}
project.inferred_project_type = app.$getProjectTypeForUrl(
project.project_type,
project.loaders
)
return project
})
}
return result
},
}
)
const url = `teams?ids=${encodeURIComponent(JSON.stringify(teamIds))}`
const { data: result } = await useAsyncData(url, () => useBaseFetch(url))
if (result.value) {
members.value = result.value
projects.value = projects.value.map((project) => {
project.owner = members.value
.flat()
.find((x) => x.team_id === project.team && x.role === 'Owner').user
project.age = project.queued ? now - app.$dayjs(project.queued) : Number.MAX_VALUE
project.age_warning = ''
if (project.age > TIME_24H * 2) {
project.age_warning = 'danger'
} else if (project.age > TIME_24H) {
project.age_warning = 'warning'
}
project.inferred_project_type = app.$getProjectTypeForUrl(
project.project_type,
project.loaders
)
return project
})
}
}
</script>
<style lang="scss" scoped>
Expand Down

0 comments on commit 27f8b49

Please sign in to comment.