aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/tabs/profile_tab.js
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2021-02-01 19:39:57 +0200
committerHenry Jameson <me@hjkos.com>2021-02-01 19:39:57 +0200
commit8958f386bef9317ff5782fa0f16164d7fbc2af21 (patch)
tree8c33fed5331c18023d608fbb366c464783559220 /src/components/settings_modal/tabs/profile_tab.js
parente695506c514e49964dfd81c7db5c5b4d4918f47d (diff)
parentde66267a07eb018cc0309ff6f9dd896d53ba3ff4 (diff)
Merge remote-tracking branch 'origin/develop' into settings-changed
* origin/develop: (306 commits) fallback if shadows aren't defined Translated using Weblate (Chinese (Traditional)) Translated using Weblate (Ukrainian) Translated using Weblate (Italian) Translated using Weblate (Ukrainian) Translated using Weblate (Portuguese) Translated using Weblate (Italian) Translated using Weblate (Russian) Translated using Weblate (Portuguese) Translated using Weblate (Russian) Translated using Weblate (Portuguese) Translated using Weblate (Portuguese) Translated using Weblate (Portuguese) Translated using Weblate (Portuguese) Translated using Weblate (Portuguese) Translated using Weblate (Portuguese) Translated using Weblate (Portuguese) Translated using Weblate (Portuguese) Translated using Weblate (Portuguese) Translated using Weblate (Portuguese) ...
Diffstat (limited to 'src/components/settings_modal/tabs/profile_tab.js')
-rw-r--r--src/components/settings_modal/tabs/profile_tab.js68
1 files changed, 39 insertions, 29 deletions
diff --git a/src/components/settings_modal/tabs/profile_tab.js b/src/components/settings_modal/tabs/profile_tab.js
index bd6bef6a..9709424c 100644
--- a/src/components/settings_modal/tabs/profile_tab.js
+++ b/src/components/settings_modal/tabs/profile_tab.js
@@ -8,6 +8,18 @@ import EmojiInput from 'src/components/emoji_input/emoji_input.vue'
import suggestor from 'src/components/emoji_input/suggestor.js'
import Autosuggest from 'src/components/autosuggest/autosuggest.vue'
import Checkbox from 'src/components/checkbox/checkbox.vue'
+import { library } from '@fortawesome/fontawesome-svg-core'
+import {
+ faTimes,
+ faPlus,
+ faCircleNotch
+} from '@fortawesome/free-solid-svg-icons'
+
+library.add(
+ faTimes,
+ faPlus,
+ faCircleNotch
+)
const ProfileTab = {
data () {
@@ -33,9 +45,7 @@ const ProfileTab = {
banner: null,
bannerPreview: null,
background: null,
- backgroundPreview: null,
- bannerUploadError: null,
- backgroundUploadError: null
+ backgroundPreview: null
}
},
components: {
@@ -56,8 +66,7 @@ const ProfileTab = {
...this.$store.state.instance.emoji,
...this.$store.state.instance.customEmoji
],
- users: this.$store.state.users.users,
- updateUsersList: (query) => this.$store.dispatch('searchUsers', { query })
+ store: this.$store
})
},
emojiSuggestor () {
@@ -67,10 +76,7 @@ const ProfileTab = {
] })
},
userSuggestor () {
- return suggestor({
- users: this.$store.state.users.users,
- updateUsersList: (query) => this.$store.dispatch('searchUsers', { query })
- })
+ return suggestor({ store: this.$store })
},
fieldsLimits () {
return this.$store.state.instance.fieldsLimits
@@ -154,18 +160,18 @@ const ProfileTab = {
if (file.size > this.$store.state.instance[slot + 'limit']) {
const filesize = fileSizeFormatService.fileSizeFormat(file.size)
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',
- {
+ this.$store.dispatch('pushGlobalNotice', {
+ messageKey: 'upload.error.message',
+ messageArgs: [
+ this.$t('upload.error.file_too_big', {
filesize: filesize.num,
filesizeunit: filesize.unit,
allowedsize: allowedsize.num,
allowedsizeunit: allowedsize.unit
- }
- )
- ].join(' ')
+ })
+ ],
+ level: 'error'
+ })
return
}
// eslint-disable-next-line no-undef
@@ -205,8 +211,9 @@ const ProfileTab = {
that.$store.commit('setCurrentUser', user)
resolve()
})
- .catch((err) => {
- reject(new Error(that.$t('upload.error.base') + ' ' + err.message))
+ .catch((error) => {
+ that.displayUploadError(error)
+ reject(error)
})
}
@@ -227,24 +234,27 @@ const ProfileTab = {
this.$store.commit('setCurrentUser', user)
this.bannerPreview = null
})
- .catch((err) => {
- this.bannerUploadError = this.$t('upload.error.base') + ' ' + err.message
- })
- .then(() => { this.bannerUploading = false })
+ .catch(this.displayUploadError)
+ .finally(() => { this.bannerUploading = false })
},
submitBackground (background) {
if (!this.backgroundPreview && background !== '') { return }
this.backgroundUploading = true
- this.$store.state.api.backendInteractor.updateProfileImages({ background }).then((data) => {
- if (!data.error) {
+ this.$store.state.api.backendInteractor.updateProfileImages({ background })
+ .then((data) => {
this.$store.commit('addNewUsers', [data])
this.$store.commit('setCurrentUser', data)
this.backgroundPreview = null
- } else {
- this.backgroundUploadError = this.$t('upload.error.base') + data.error
- }
- this.backgroundUploading = false
+ })
+ .catch(this.displayUploadError)
+ .finally(() => { this.backgroundUploading = false })
+ },
+ displayUploadError (error) {
+ this.$store.dispatch('pushGlobalNotice', {
+ messageKey: 'upload.error.message',
+ messageArgs: [error.message],
+ level: 'error'
})
}
}