Skip to content

Commit

Permalink
Issue #100: Set small and medium sized image to null before saving
Browse files Browse the repository at this point in the history
  • Loading branch information
Amar-Bolkan committed May 3, 2022
1 parent d053abf commit 061a0c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public ImageDTO save(final ImageDTO image) {
image.setSmallContentType(null);
image.setHash(null);
}

// TODO: See Issue #100
if (shouldResizeImage(image)) {
// FIXME: Validate the input (https://github.com/iteratec/TeamDojo/issues/11)
final var large = image.getLarge();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ export class TeamsEditComponent implements OnInit {
}
},
error: (err: FileLoadError) =>
this.eventManager.broadcast(
new EventWithContent<AlertError>('teamDojoApp.error', { ...err, key: 'error.file.' + err.key })
),
this.eventManager.broadcast(new EventWithContent<AlertError>('teamDojoApp.error', { ...err, key: 'error.file.' + err.key })),
});
}

Expand Down Expand Up @@ -183,8 +181,23 @@ export class TeamsEditComponent implements OnInit {
);
}

/**
* small and medium size image needs to be set to null, otherwise the backend will not
* set them automatically.
* @param image
* @private
*/
private clearMediumAndSmallSizeImage(image: IImage): void {
image.small = null;
image.smallContentType = null;
image.medium = null;
image.mediumContentType = null;
}

private setImageFromEditForm(image: IImage): void {
image.large = this.editForm.value.large;
image.largeContentType = this.editForm.value.largeContentType;
// TODO: Issue #100 this might not be needed
this.clearMediumAndSmallSizeImage(image);
}
}

0 comments on commit 061a0c9

Please sign in to comment.