Skip to content

Commit

Permalink
Merge pull request #739 from sitaradev/profile-urls
Browse files Browse the repository at this point in the history
fixed new user urls crash
  • Loading branch information
gagansuie authored Oct 7, 2023
2 parents 185dcf2 + 6d00d17 commit ae56610
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/lib/components/Profile/DrawerEditProfile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
export let profile: any
let isProfileUpdated = objectMonitor($page.data.profile)
$: inputFields = profile.urls ? [...profile.urls] : []
let inputFields = [...profile.urls]
$: if (!inputFields.length) {
inputFields = ['']
}
const removeInputField = (index: number) => {
inputFields = inputFields.filter((_, i) => i !== index)
Expand Down
4 changes: 3 additions & 1 deletion src/routes/[username]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ export const load = (async ({ params }: { params: any }) => {
export const actions = {
'update-profile': async ({ request, locals }: { request: any; locals: any }) => {
const data: FormData = await request.formData()
const newUser: any = {}
let newUser: any = {}
addPropertyIfDefined(data, 'displayName', newUser)
addPropertyIfDefined(data, 'username', newUser)
addPropertyIfDefined(data, 'category', newUser)
addPropertyIfDefined(data, 'bio', newUser)
addPropertyIfDefined(data, 'urls', newUser, true)

newUser.urls = newUser.urls.filter((i:string) => i)

const avatar = data.get('avatar') as File

const banner = data.get('banner') as File
Expand Down

0 comments on commit ae56610

Please sign in to comment.