mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 03:43:28 +10:00
Bug fix: Ensure that file exists when showing ImageFromFile component
This commit is contained in:
parent
01e0078890
commit
ea6c39b86e
1 changed files with 8 additions and 4 deletions
|
|
@ -44,8 +44,10 @@ const RenderAvatar = props => {
|
|||
name={name}
|
||||
onChange={event => {
|
||||
const file = event.target.files[0];
|
||||
const tempId = `${file.name}_${Date.now()}`;
|
||||
onChange({ id: tempId, file });
|
||||
if (file != null) {
|
||||
const tempId = `${file.name}_${Date.now()}`;
|
||||
onChange({ id: tempId, file });
|
||||
}
|
||||
}}
|
||||
type={type}
|
||||
/>
|
||||
|
|
@ -152,9 +154,11 @@ class ProfileSettingsFormComponent extends Component {
|
|||
const transientUserProfileImage = profileImage.uploadedImage || user.profileImage;
|
||||
const transientUser = { ...user, profileImage: transientUserProfileImage };
|
||||
|
||||
const fileUploadInProgress = uploadInProgress && profileImage.file;
|
||||
// Ensure that file exists if imageFromFile is used
|
||||
const fileExists = !!profileImage.file;
|
||||
const fileUploadInProgress = uploadInProgress && fileExists;
|
||||
const delayAfterUpload = profileImage.imageId && this.state.uploadDelay;
|
||||
const imageFromFile = fileUploadInProgress || delayAfterUpload
|
||||
const imageFromFile = fileExists && (fileUploadInProgress || delayAfterUpload)
|
||||
? <ImageFromFile
|
||||
id={profileImage.id}
|
||||
className={errorClasses}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue