From 37c10be5e29815057b4b1adcd268b9f4cb5b415e Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 16 Apr 2017 13:44:11 +0200 Subject: Add basic avatar changing. --- src/components/settings/settings.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/components/settings/settings.js') diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 4d0528b6..347dd8f2 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -13,6 +13,28 @@ const settings = { components: { StyleSwitcher }, + computed: { + user () { + return this.$store.state.users.currentUser + } + }, + methods: { + uploadAvatar ({target}) { + const file = target.files[0] + const reader = new FileReader() + reader.onload = ({target}) => { + const img = target.result + + this.$store.state.api.backendInteractor.updateAvatar({params: {img}}).then((user) => { + if (!user.error) { + this.$store.commit('addNewUsers', [user]) + this.$store.commit('setCurrentUser', user) + } + }) + } + reader.readAsDataURL(file) + } + }, watch: { hideAttachmentsLocal (value) { this.$store.dispatch('setOption', { name: 'hideAttachments', value }) -- cgit v1.2.3-70-g09d2