From 25a04f2294a4ed4d9cf527d8ee2d2899400447dd Mon Sep 17 00:00:00 2001 From: Rinpatch Date: Tue, 11 Dec 2018 16:02:35 +0300 Subject: Avatar, background, banner filesize errors --- src/components/user_settings/user_settings.js | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 761e674a..ed9178fa 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -1,9 +1,13 @@ import TabSwitcher from '../tab_switcher/tab_switcher.jsx' import StyleSwitcher from '../style_switcher/style_switcher.vue' +import fileSizeFormatService from '../../services/file_size_format/file_size_format.js' const UserSettings = { data () { return { + avataruploaderror: null, + backgrounduploaderror: null, + banneruploaderror: null, newname: this.$store.state.users.currentUser.name, newbio: this.$store.state.users.currentUser.description, newlocked: this.$store.state.users.currentUser.locked, @@ -69,6 +73,29 @@ 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) { + 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})) + return + } // eslint-disable-next-line no-undef const reader = new FileReader() reader.onload = ({target}) => { @@ -107,6 +134,19 @@ const UserSettings = { this.uploading[0] = false }) }, + clearUploadError (slot) { + switch (slot) { + case 0: + this.avataruploaderror = null + break + case 1: + this.banneruploaderror = null + break + case 2: + this.backgrounduploaderror = null + break + } + }, submitBanner () { if (!this.previews[1]) { return } -- cgit v1.2.3-70-g09d2 From bf8bb9ce134c8712885e52d005c6d130fca4e553 Mon Sep 17 00:00:00 2001 From: Rinpatch Date: Wed, 12 Dec 2018 16:38:01 +0300 Subject: Moved upload errors in user_settings to an array. Moved upload error strings to its separate section in i18n --- src/components/media_upload/media_upload.js | 4 +-- .../post_status_form/post_status_form.js | 2 +- src/components/user_settings/user_settings.js | 41 ++++------------------ src/components/user_settings/user_settings.vue | 12 +++---- src/i18n/en.json | 22 +++++++----- 5 files changed, 29 insertions(+), 52 deletions(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js index 31d36487..42d900d3 100644 --- a/src/components/media_upload/media_upload.js +++ b/src/components/media_upload/media_upload.js @@ -25,7 +25,7 @@ const mediaUpload = { if (file.size > store.state.instance.uploadlimit) { const filesize = fileSizeFormatService.fileSizeFormat(file.size) const allowedsize = fileSizeFormatService.fileSizeFormat(store.state.instance.uploadlimit) - self.$emit('upload-failed', 'upload_error_file_too_big', {filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit}) + self.$emit('upload-failed', 'file_too_big', {filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit}) return } const formData = new FormData() @@ -39,7 +39,7 @@ const mediaUpload = { self.$emit('uploaded', fileData) self.uploading = false }, (error) => { // eslint-disable-line handle-callback-err - self.$emit('upload-failed', 'upload_error_generic') + self.$emit('upload-failed', 'default') self.uploading = false }) }, diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index f8225fb2..3899027f 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -264,7 +264,7 @@ const PostStatusForm = { }, uploadFailed (errString, templateArgs) { templateArgs = templateArgs || {} - this.error = this.$t('post_status.upload_error') + ' ' + this.$t('post_status.' + errString, templateArgs) + this.error = this.$t('upload.error.base') + ' ' + this.$t('upload.error.' + errString, templateArgs) this.enableSubmit() }, disableSubmit () { 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 } diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue index 12bc953e..22c4fe41 100644 --- a/src/components/user_settings/user_settings.vue +++ b/src/components/user_settings/user_settings.vue @@ -43,8 +43,8 @@ -
- Error: {{ avataruploaderror }} +
+ Error: {{ uploaderror[0] }}
@@ -60,8 +60,8 @@ -
- Error: {{ banneruploaderror }} +
+ Error: {{ uploaderror[1] }}
@@ -75,8 +75,8 @@ -
- Error: {{ backgrounduploaderror }} +
+ Error: {{ uploaderror[2] }}
diff --git a/src/i18n/en.json b/src/i18n/en.json index 5697bae7..dae2f286 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -52,9 +52,6 @@ "account_not_locked_warning": "Your account is not {0}. Anyone can follow you to view your follower-only posts.", "account_not_locked_warning_link": "locked", "attachments_sensitive": "Mark attachments as sensitive", - "upload_error": "Upload failed.", - "upload_error_file_too_big": "File too big [{filesize}{filesizeunit} / {allowedsize}{allowedsizeunit}]", - "upload_error_generic": "Try again later", "content_type": { "plain_text": "Plain text" }, @@ -230,11 +227,18 @@ "favorite": "Favorite", "user_settings": "User Settings" }, - "file_size_units": { - "B": "B", - "KiB": "KiB", - "MiB": "MiB", - "GiB": "GiB", - "TiB": "TiB" + "upload":{ + "error": { + "base": "Upload failed.", + "file_too_big": "File too big [{filesize}{filesizeunit} / {allowedsize}{allowedsizeunit}]", + "default": "Try again later" + }, + "file_size_units": { + "B": "B", + "KiB": "KiB", + "MiB": "MiB", + "GiB": "GiB", + "TiB": "TiB" + } } } -- cgit v1.2.3-70-g09d2 From 5ca2e75df36f3848f6003da2525051c8e9e275b1 Mon Sep 17 00:00:00 2001 From: Rinpatch Date: Wed, 12 Dec 2018 19:31:16 +0300 Subject: Handle errors from server --- src/components/user_settings/user_settings.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 424d0b85..cf37e71a 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -113,6 +113,8 @@ const UserSettings = { this.$store.commit('addNewUsers', [user]) this.$store.commit('setCurrentUser', user) this.previews[0] = null + } else { + this.$set(this.uploaderror, 0, this.$t('upload.error.base') + user.error) } this.uploading[0] = false }) @@ -141,6 +143,8 @@ const UserSettings = { this.$store.commit('addNewUsers', [clone]) this.$store.commit('setCurrentUser', clone) this.previews[1] = null + } else { + this.$set(this.uploaderror, 1, this.$t('upload.error.base') + data.error) } this.uploading[1] = false }) @@ -165,6 +169,8 @@ const UserSettings = { this.$store.commit('addNewUsers', [clone]) this.$store.commit('setCurrentUser', clone) this.previews[2] = null + } else { + this.$set(this.uploaderror, 2, this.$t('upload.error.base') + data.error) } this.uploading[2] = false }) -- cgit v1.2.3-70-g09d2 From 9c24ac1d050914861891bd1f5137159e91890d86 Mon Sep 17 00:00:00 2001 From: Rinpatch Date: Wed, 12 Dec 2018 20:01:37 +0300 Subject: I am dumb --- src/components/user_settings/user_settings.js | 1 - 1 file changed, 1 deletion(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index cf37e71a..504976a5 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -72,7 +72,6 @@ const UserSettings = { const file = e.target.files[0] if (!file) { return } 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[slot]) -- cgit v1.2.3-70-g09d2 From 33c2d21bb7ca21ed0e7358aac7721c48d13aa03c Mon Sep 17 00:00:00 2001 From: link0ff Date: Wed, 12 Dec 2018 22:00:04 +0200 Subject: Reset enableFollowsExport to true after 2 sec when an export file is available to download --- src/components/user_settings/user_settings.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 761e674a..1712e64c 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -198,6 +198,7 @@ const UserSettings = { .fetchFriends({id: this.$store.state.users.currentUser.id}) .then((friendList) => { this.exportPeople(friendList, 'friends.csv') + setTimeout(() => { this.enableFollowsExport = true }, 2000) }) }, followListChange () { -- cgit v1.2.3-70-g09d2 From 48edc0c8fcc6c63e432c9b6d78f14af086b56900 Mon Sep 17 00:00:00 2001 From: Rinpatch Date: Thu, 13 Dec 2018 11:25:03 +0300 Subject: Refactor arrays to individual options --- src/components/user_settings/user_settings.js | 94 ++++++++++++++++++-------- src/components/user_settings/user_settings.vue | 32 ++++----- 2 files changed, 83 insertions(+), 43 deletions(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 504976a5..0f3f0859 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -5,7 +5,6 @@ import fileSizeFormatService from '../../services/file_size_format/file_size_for const UserSettings = { data () { return { - 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, @@ -15,8 +14,16 @@ const UserSettings = { followImportError: false, followsImported: false, enableFollowsExport: true, - uploading: [ false, false, false, false ], - previews: [ null, null, null ], + avatarUploading: false, + bannerUploading: false, + backgroundUploading: false, + followListUploading: false, + avatarPreview: null, + bannerPreview: null, + backgroundPreview: null, + avatarUploadError: null, + bannerUploadError: null, + backgroundUploadError: null, deletingAccount: false, deleteAccountConfirmPasswordInput: '', deleteAccountError: false, @@ -71,26 +78,49 @@ const UserSettings = { uploadFile (slot, e) { const file = e.target.files[0] if (!file) { return } + var error = () => {} + switch (slot) { + case 0: + error = (error) => { this.avatarUploadError = error } + break + case 1: + error = (error) => { this.bannerUploadError = error } + break + case 2: + error = (error) => { this.backgroundUploadError = error } + break + } var limit = [this.$store.state.instance.avatarlimit, this.$store.state.instance.bannerlimit, this.$store.state.instance.backgroundlimit] if (file.size > limit[slot]) { const filesize = fileSizeFormatService.fileSizeFormat(file.size) 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})) + error(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 const reader = new FileReader() reader.onload = ({target}) => { const img = target.result - this.previews[slot] = img - this.$forceUpdate() // just changing the array with the index doesn't update the view + var preview = () => {} + switch (slot) { + case 0: + preview = (preview) => { this.avatarPreview = preview } + break + case 1: + preview = (preview) => { this.bannerPreview = preview } + break + case 2: + preview = (preview) => { this.backgroundPreview = preview } + break + } + preview(img) } reader.readAsDataURL(file) }, submitAvatar () { - if (!this.previews[0]) { return } + if (!this.avatarPreview) { return } - let img = this.previews[0] + let img = this.avatarPreview // eslint-disable-next-line no-undef let imginfo = new Image() let cropX, cropY, cropW, cropH @@ -106,25 +136,35 @@ const UserSettings = { cropX = Math.floor((imginfo.width - imginfo.height) / 2) cropW = imginfo.height } - this.uploading[0] = true + this.avatarUploading = true this.$store.state.api.backendInteractor.updateAvatar({params: {img, cropX, cropY, cropW, cropH}}).then((user) => { if (!user.error) { this.$store.commit('addNewUsers', [user]) this.$store.commit('setCurrentUser', user) - this.previews[0] = null + this.avatarPreview = null } else { - this.$set(this.uploaderror, 0, this.$t('upload.error.base') + user.error) + this.avatarUploadError = this.$t('upload.error.base') + user.error } - this.uploading[0] = false + this.avatarUploading = false }) }, clearUploadError (slot) { - this.$set(this.uploaderror, slot, null) + switch (slot) { + case 0: + this.avatarUploadError = null + break + case 1: + this.bannerUploadError = null + break + case 2: + this.backgroundUploadError = null + break + } }, submitBanner () { - if (!this.previews[1]) { return } + if (!this.bannerPreview) { return } - let banner = this.previews[1] + let banner = this.bannerPreview // eslint-disable-next-line no-undef let imginfo = new Image() /* eslint-disable camelcase */ @@ -134,24 +174,24 @@ const UserSettings = { height = imginfo.height offset_top = 0 offset_left = 0 - this.uploading[1] = true + this.bannerUploading = true this.$store.state.api.backendInteractor.updateBanner({params: {banner, offset_top, offset_left, width, height}}).then((data) => { if (!data.error) { let clone = JSON.parse(JSON.stringify(this.$store.state.users.currentUser)) clone.cover_photo = data.url this.$store.commit('addNewUsers', [clone]) this.$store.commit('setCurrentUser', clone) - this.previews[1] = null + this.bannerPreview = null } else { - this.$set(this.uploaderror, 1, this.$t('upload.error.base') + data.error) + this.bannerUploadError = this.$t('upload.error.base') + data.error } - this.uploading[1] = false + this.bannerUploading = false }) /* eslint-enable camelcase */ }, submitBg () { - if (!this.previews[2]) { return } - let img = this.previews[2] + if (!this.backgroundPreview) { return } + let img = this.backgroundPreview // eslint-disable-next-line no-undef let imginfo = new Image() let cropX, cropY, cropW, cropH @@ -160,22 +200,22 @@ const UserSettings = { cropY = 0 cropW = imginfo.width cropH = imginfo.width - this.uploading[2] = true + this.backgroundUploading = true this.$store.state.api.backendInteractor.updateBg({params: {img, cropX, cropY, cropW, cropH}}).then((data) => { if (!data.error) { let clone = JSON.parse(JSON.stringify(this.$store.state.users.currentUser)) clone.background_image = data.url this.$store.commit('addNewUsers', [clone]) this.$store.commit('setCurrentUser', clone) - this.previews[2] = null + this.backgroundPreview = null } else { - this.$set(this.uploaderror, 2, this.$t('upload.error.base') + data.error) + this.backgroundUploadError = this.$t('upload.error.base') + data.error } - this.uploading[2] = false + this.backgroundUploading = false }) }, importFollows () { - this.uploading[3] = true + this.followListUploading = true const followList = this.followList this.$store.state.api.backendInteractor.followImport({params: followList}) .then((status) => { @@ -184,7 +224,7 @@ const UserSettings = { } else { this.followImportError = true } - this.uploading[3] = false + this.followListUploading = false }) }, /* This function takes an Array of Users diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue index 22c4fe41..5883775c 100644 --- a/src/components/user_settings/user_settings.vue +++ b/src/components/user_settings/user_settings.vue @@ -36,15 +36,15 @@

{{$t('settings.current_avatar')}}

{{$t('settings.set_new_avatar')}}

- +
- - -
- Error: {{ uploaderror[0] }} + + +
+ Error: {{ avatarUploadError }}
@@ -53,30 +53,30 @@

{{$t('settings.current_profile_banner')}}

{{$t('settings.set_new_profile_banner')}}

- +
- - -
- Error: {{ uploaderror[1] }} + + +
+ Error: {{ bannerUploadError }}

{{$t('settings.profile_background')}}

{{$t('settings.set_new_profile_background')}}

- +
- - -
- Error: {{ uploaderror[2] }} + + +
+ Error: {{ backgroundUploadError }}
@@ -125,7 +125,7 @@
- +
-- cgit v1.2.3-70-g09d2 From c52b8019ae6a248a392f925c8ec5086289ce679e Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 13 Dec 2018 15:58:38 +0300 Subject: added hide_network option, fixed properties naming --- src/components/user_settings/user_settings.js | 55 ++++++++++++++++---------- src/components/user_settings/user_settings.vue | 14 ++++--- src/i18n/en.json | 1 + src/i18n/ru.json | 1 + 4 files changed, 46 insertions(+), 25 deletions(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 761e674a..8e57894c 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -4,11 +4,12 @@ import StyleSwitcher from '../style_switcher/style_switcher.vue' const UserSettings = { data () { return { - newname: this.$store.state.users.currentUser.name, - newbio: this.$store.state.users.currentUser.description, - newlocked: this.$store.state.users.currentUser.locked, - newnorichtext: this.$store.state.users.currentUser.no_rich_text, - newdefaultScope: this.$store.state.users.currentUser.default_scope, + newName: this.$store.state.users.currentUser.name, + newBio: this.$store.state.users.currentUser.description, + newLocked: this.$store.state.users.currentUser.locked, + newNoRichText: this.$store.state.users.currentUser.no_rich_text, + newDefaultScope: this.$store.state.users.currentUser.default_scope, + newHideNetwork: this.$store.state.users.currentUser.hide_network, followList: null, followImportError: false, followsImported: false, @@ -40,31 +41,45 @@ const UserSettings = { }, vis () { return { - public: { selected: this.newdefaultScope === 'public' }, - unlisted: { selected: this.newdefaultScope === 'unlisted' }, - private: { selected: this.newdefaultScope === 'private' }, - direct: { selected: this.newdefaultScope === 'direct' } + public: { selected: this.newDefaultScope === 'public' }, + unlisted: { selected: this.newDefaultScope === 'unlisted' }, + private: { selected: this.newDefaultScope === 'private' }, + direct: { selected: this.newDefaultScope === 'direct' } } } }, methods: { updateProfile () { const name = this.newname - const description = this.newbio - const locked = this.newlocked + const description = this.newBio + const locked = this.newLocked + // Backend notation. /* eslint-disable camelcase */ - const default_scope = this.newdefaultScope - const no_rich_text = this.newnorichtext - this.$store.state.api.backendInteractor.updateProfile({params: {name, description, locked, default_scope, no_rich_text}}).then((user) => { - if (!user.error) { - this.$store.commit('addNewUsers', [user]) - this.$store.commit('setCurrentUser', user) - } - }) + const default_scope = this.newDefaultScope + const no_rich_text = this.newNoRichText + const hide_network = this.newHideNetwork /* eslint-enable camelcase */ + this.$store.state.api.backendInteractor + .updateProfile({ + params: { + name, + description, + locked, + // Backend notation. + /* eslint-disable camelcase */ + default_scope, + no_rich_text, + hide_network + /* eslint-enable camelcase */ + }}).then((user) => { + if (!user.error) { + this.$store.commit('addNewUsers', [user]) + this.$store.commit('setCurrentUser', user) + } + }) }, changeVis (visibility) { - this.newdefaultScope = visibility + this.newDefaultScope = visibility }, uploadFile (slot, e) { const file = e.target.files[0] diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue index 234a7d86..11629440 100644 --- a/src/components/user_settings/user_settings.vue +++ b/src/components/user_settings/user_settings.vue @@ -9,11 +9,11 @@

{{$t('settings.name_bio')}}

{{$t('settings.name')}}

- +

{{$t('settings.bio')}}

- +

- +

@@ -26,10 +26,14 @@

- +

- +

+ + +

+

{{$t('settings.avatar')}}

diff --git a/src/i18n/en.json b/src/i18n/en.json index 92429e4b..b094e9b8 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -151,6 +151,7 @@ "notification_visibility_mentions": "Mentions", "notification_visibility_repeats": "Repeats", "no_rich_text_description": "Strip rich text formatting from all posts", + "hide_network_description": "Don't show who I'm following and who's following me", "nsfw_clickthrough": "Enable clickthrough NSFW attachment hiding", "panelRadius": "Panels", "pause_on_unfocused": "Pause streaming when tab is not focused", diff --git a/src/i18n/ru.json b/src/i18n/ru.json index c764005a..13c7fec3 100644 --- a/src/i18n/ru.json +++ b/src/i18n/ru.json @@ -126,6 +126,7 @@ "notification_visibility_mentions": "Упоминания", "notification_visibility_repeats": "Повторы", "no_rich_text_description": "Убрать форматирование из всех постов", + "hide_network_description": "Не показывать кого я читаю и кто меня читает", "nsfw_clickthrough": "Включить скрытие NSFW вложений", "panelRadius": "Панели", "pause_on_unfocused": "Приостановить загрузку когда вкладка не в фокусе", -- cgit v1.2.3-70-g09d2 From 457132fb378b70a630fd4dc1b723488901b95c83 Mon Sep 17 00:00:00 2001 From: rinpatch Date: Thu, 13 Dec 2018 15:44:37 +0100 Subject: get rid of slots --- src/components/user_settings/user_settings.js | 40 ++------------------------ src/components/user_settings/user_settings.vue | 12 ++++---- 2 files changed, 9 insertions(+), 43 deletions(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 0f3f0859..88cdb3bf 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -78,42 +78,18 @@ const UserSettings = { uploadFile (slot, e) { const file = e.target.files[0] if (!file) { return } - var error = () => {} - switch (slot) { - case 0: - error = (error) => { this.avatarUploadError = error } - break - case 1: - error = (error) => { this.bannerUploadError = error } - break - case 2: - error = (error) => { this.backgroundUploadError = error } - break - } var limit = [this.$store.state.instance.avatarlimit, this.$store.state.instance.bannerlimit, this.$store.state.instance.backgroundlimit] if (file.size > limit[slot]) { const filesize = fileSizeFormatService.fileSizeFormat(file.size) const allowedsize = fileSizeFormatService.fileSizeFormat(limit[slot]) - error(this.$t('upload.error.base') + ' ' + this.$t('upload.error.file_too_big', {filesize: filesize.num, filesizeunit: filesize.unit, allowedsize: allowedsize.num, allowedsizeunit: allowedsize.unit})) + this[slot + 'UploadError'] = 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 const reader = new FileReader() reader.onload = ({target}) => { const img = target.result - var preview = () => {} - switch (slot) { - case 0: - preview = (preview) => { this.avatarPreview = preview } - break - case 1: - preview = (preview) => { this.bannerPreview = preview } - break - case 2: - preview = (preview) => { this.backgroundPreview = preview } - break - } - preview(img) + this[slot + 'Preview'] = img } reader.readAsDataURL(file) }, @@ -149,17 +125,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[slot + 'UploadError'] = null }, submitBanner () { if (!this.bannerPreview) { return } diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue index 5883775c..1a98b788 100644 --- a/src/components/user_settings/user_settings.vue +++ b/src/components/user_settings/user_settings.vue @@ -39,13 +39,13 @@
- +
Error: {{ avatarUploadError }} - +
@@ -56,13 +56,13 @@
- +
Error: {{ bannerUploadError }} - +
@@ -71,13 +71,13 @@
- +
Error: {{ backgroundUploadError }} - +
-- cgit v1.2.3-70-g09d2 From dd6a9ae6458784b36ffe2376492284ae4e79fece Mon Sep 17 00:00:00 2001 From: Rinpatch Date: Thu, 13 Dec 2018 17:51:29 +0300 Subject: oof --- src/components/user_settings/user_settings.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 88cdb3bf..43e39b13 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -78,10 +78,9 @@ const UserSettings = { uploadFile (slot, e) { const file = e.target.files[0] if (!file) { return } - var limit = [this.$store.state.instance.avatarlimit, this.$store.state.instance.bannerlimit, this.$store.state.instance.backgroundlimit] - if (file.size > limit[slot]) { + if (file.size > this.$store.state.instance[slot + 'limit']) { const filesize = fileSizeFormatService.fileSizeFormat(file.size) - const allowedsize = fileSizeFormatService.fileSizeFormat(limit[slot]) + const allowedsize = fileSizeFormatService.fileSizeFormat(this.$store.state.instance[slot + 'limit']) this[slot + 'UploadError'] = 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 } -- cgit v1.2.3-70-g09d2 From 7d3385f34990be7ccb226528334074c8c43d99c5 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sat, 15 Dec 2018 03:30:39 +0300 Subject: fix --- src/components/user_settings/user_settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index ca7bf319..ee989f71 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -59,7 +59,7 @@ const UserSettings = { }, methods: { updateProfile () { - const name = this.newname + const name = this.newName const description = this.newBio const locked = this.newLocked // Backend notation. -- cgit v1.2.3-70-g09d2