aboutsummaryrefslogtreecommitdiff
path: root/src/components/user_settings/user_settings.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/user_settings/user_settings.js')
-rw-r--r--src/components/user_settings/user_settings.js41
1 files changed, 7 insertions, 34 deletions
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index ed9178fa..424d0b85 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -5,9 +5,7 @@ import fileSizeFormatService from '../../services/file_size_format/file_size_for
const UserSettings = {
data () {
return {
- avataruploaderror: null,
- backgrounduploaderror: null,
- banneruploaderror: null,
+ uploaderror: [null, null, null],
newname: this.$store.state.users.currentUser.name,
newbio: this.$store.state.users.currentUser.description,
newlocked: this.$store.state.users.currentUser.locked,
@@ -73,27 +71,12 @@ const UserSettings = {
uploadFile (slot, e) {
const file = e.target.files[0]
if (!file) { return }
- var limit = 0
- var error = () => {}
- switch (slot) {
- case 0:
- limit = this.$store.state.instance.avatarlimit
- error = (error) => { this.avataruploaderror = error }
- break
- case 1:
- limit = this.$store.state.instance.bannerlimit
- error = (error) => { this.banneruploaderror = error }
- break
- case 2:
- limit = this.$store.state.instance.backgroundlimit
- error = (error) => { this.backgrounduploaderror = error }
- }
- console.log(this.$store)
- console.log(file.size + ' ' + slot + ' ' + limit)
- if (file.size > limit) {
+ var limit = [this.$store.state.instance.avatarlimit, this.$store.state.instance.bannerlimit, this.$store.state.instance.backgroundlimit]
+ console.log(file.size, limit)
+ if (file.size > limit[slot]) {
const filesize = fileSizeFormatService.fileSizeFormat(file.size)
- const allowedsize = fileSizeFormatService.fileSizeFormat(limit)
- error(this.$t('post_status.upload_error_file_too_big', {filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit}))
+ const allowedsize = fileSizeFormatService.fileSizeFormat(limit[slot])
+ this.$set(this.uploaderror, slot, this.$t('upload.error.base') + ' ' + this.$t('upload.error.file_too_big', {filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit}))
return
}
// eslint-disable-next-line no-undef
@@ -135,17 +118,7 @@ const UserSettings = {
})
},
clearUploadError (slot) {
- switch (slot) {
- case 0:
- this.avataruploaderror = null
- break
- case 1:
- this.banneruploaderror = null
- break
- case 2:
- this.backgrounduploaderror = null
- break
- }
+ this.$set(this.uploaderror, slot, null)
},
submitBanner () {
if (!this.previews[1]) { return }