mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 23:03:00 -04:00
fix(theming): display error messages on image upload and delete previous image only after validation
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
This commit is contained in:
parent
4d6959da27
commit
0a5f75e719
2 changed files with 11 additions and 2 deletions
|
|
@ -221,8 +221,6 @@ class ImageManager {
|
|||
}
|
||||
|
||||
public function updateImage(string $key, string $tmpFile): string {
|
||||
$this->delete($key);
|
||||
|
||||
try {
|
||||
$folder = $this->getRootFolder()->getFolder('images');
|
||||
} catch (NotFoundException $e) {
|
||||
|
|
@ -236,6 +234,8 @@ class ImageManager {
|
|||
throw new \Exception('Unsupported image type: ' . $detectedMimeType);
|
||||
}
|
||||
|
||||
$this->delete($key);
|
||||
|
||||
if ($key === 'background') {
|
||||
if ($this->shouldOptimizeBackgroundImage($detectedMimeType, filesize($tmpFile))) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -76,8 +76,17 @@ async function onChange() {
|
|||
})
|
||||
mime.value = file.type
|
||||
emit('updated')
|
||||
} catch (error: any) {
|
||||
if (error?.response?.status === 422) {
|
||||
const serverMessage = error.response.data?.data?.message
|
||||
showError(serverMessage || t('theming', 'Failed to upload image'))
|
||||
} else {
|
||||
showError(t('theming', 'Failed to upload image'))
|
||||
}
|
||||
} finally {
|
||||
isSaving.value = false
|
||||
// Reset input to allow re-selecting the same file and show validation errors on every attempt
|
||||
inputElement.value!.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue