Merge branch 'develop' into Syldexia/pleroma-fe-feature/account-deletion

This commit is contained in:
Roger Braun 2018-05-20 13:16:49 +02:00
commit 959b2d9d66
5 changed files with 72 additions and 29 deletions

View file

@ -8,6 +8,7 @@ const UserSettings = {
followList: null,
followImportError: false,
followsImported: false,
enableFollowsExport: true,
uploading: [ false, false, false, false ],
previews: [ null, null, null ],
deletingAccount: false,
@ -140,6 +141,37 @@ const UserSettings = {
this.uploading[3] = false
})
},
/* This function takes an Array of Users
* and outputs a file with all the addresses for the user to download
*/
exportPeople (users, filename) {
// Get all the friends addresses
var UserAddresses = users.map(function (user) {
// check is it's a local user
if (user && user.is_local) {
// append the instance address
// eslint-disable-next-line no-undef
user.screen_name += '@' + location.hostname
}
return user.screen_name
}).join('\n')
// Make the user download the file
var fileToDownload = document.createElement('a')
fileToDownload.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(UserAddresses))
fileToDownload.setAttribute('download', filename)
fileToDownload.style.display = 'none'
document.body.appendChild(fileToDownload)
fileToDownload.click()
document.body.removeChild(fileToDownload)
},
exportFollows () {
this.enableFollowsExport = false
this.$store.state.api.backendInteractor
.fetchFriends({id: this.$store.state.users.currentUser.id})
.then((friendList) => {
this.exportPeople(friendList, 'friends.csv')
})
},
followListChange () {
// eslint-disable-next-line no-undef
let formData = new FormData()
@ -156,10 +188,9 @@ const UserSettings = {
deleteAccount () {
this.$store.state.api.backendInteractor.deleteAccount({password: this.deleteAccountConfirmPasswordInput})
.then((res) => {
console.log(res)
if (res.status === 'success') {
this.$store.dispatch('logout')
window.location.href = '/main/all'
this.$router.push('/main/all')
} else {
this.deleteAccountError = res.error
}