Add basic avatar changing.

This commit is contained in:
Roger Braun 2017-04-16 13:44:11 +02:00
parent 55edd6d8c2
commit 37c10be5e2
4 changed files with 58 additions and 2 deletions

View file

@ -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 })

View file

@ -8,6 +8,13 @@
<h2>Theme</h2>
<style-switcher></style-switcher>
</div>
<div class="setting-item">
<h2>Avatar</h2>
<img :src="user.profile_image_url_original"></img>
<div>
<input name="avatar-upload" id="avatar-upload" type="file" @change="uploadAvatar" ></input>
</div>
</div>
<div class="setting-item">
<h2>Filtering</h2>
<p>All notices containing these words will be muted, one per line</p>