Selaa lähdekoodia

fix: avatar is not updated after setted (#25414)

tags/1.9.0
Joel 2 kuukautta sitten
vanhempi
commit
4c92e63b0b
No account linked to committer's email address

+ 1
- 1
web/app/account/(commonLayout)/account-page/AvatarWithEdit.tsx Näytä tiedosto

const handleSaveAvatar = useCallback(async (uploadedFileId: string) => { const handleSaveAvatar = useCallback(async (uploadedFileId: string) => {
try { try {
await updateUserProfile({ url: 'account/avatar', body: { avatar: uploadedFileId } }) await updateUserProfile({ url: 'account/avatar', body: { avatar: uploadedFileId } })
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
setIsShowAvatarPicker(false) setIsShowAvatarPicker(false)
onSave?.() onSave?.()
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
} }
catch (e) { catch (e) {
notify({ type: 'error', message: (e as Error).message }) notify({ type: 'error', message: (e as Error).message })

+ 7
- 1
web/app/components/base/avatar/index.tsx Näytä tiedosto

'use client' 'use client'
import { useState } from 'react'
import { useEffect, useState } from 'react'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'


export type AvatarProps = { export type AvatarProps = {
onError?.(true) onError?.(true)
} }


// after uploaded, api would first return error imgs url: '.../files//file-preview/...'. Then return the right url, Which caused not show the avatar
useEffect(() => {
if(avatar && imgError)
setImgError(false)
}, [avatar])

if (avatar && !imgError) { if (avatar && !imgError) {
return ( return (
<img <img

Loading…
Peruuta
Tallenna