diff --git a/src/pages/Wallpapers.vue b/src/pages/Wallpapers.vue index a98d9089..2032d841 100644 --- a/src/pages/Wallpapers.vue +++ b/src/pages/Wallpapers.vue @@ -14,86 +14,49 @@ - -
{{ $t('wallpapers.form.label') }}
- + {{ $t('wallpapers.form.duplicateMessage', { fileName: file.name }) }} - - - - {{ $t('wallpapers.form.upload') }} -
{{ $t('wallpapers.list.title') }}
- - - - - - -

{{ wallpaper.name }}

- - - -
-
- - + + + You don't have any wallpapers.
@@ -130,19 +93,27 @@ export default { methods: { async uploadWallpaper() { - const { file } = this; + if (this.isDuplicate) { + return this.$bvToast.toast('File already exists', { title: '!', variant: 'warning' }); + } + + if (!this.file) { + return; + } + this.saving = true; - await this.$store.dispatch('UPLOAD_WALLPAPER', file) + this.$store.dispatch('UPLOAD_WALLPAPER', this.file) + .then(() => { + this.$bvToast.toast('File uploaded', { title: 'Success', variant: 'success' }); + this.file = null; + this.saving = false; + this.$bus.$emit('WALLPAPER_UPLOADED'); + }) .catch(() => { this.saving = false; this.$bvToast.toast('There was an error uploading wallpaper', { title: 'Error', variant: 'danger' }); }); - - this.file = null; - this.saving = false; - this.$bvToast.toast(file.name, { title: 'File uploaded', variant: 'success' }); - this.$bus.$emit('WALLPAPER_UPLOADED'); }, confirmDeleteWallpaper(file) {