diff options
| author | lambda <pleromagit@rogerbraun.net> | 2018-05-18 07:51:00 +0000 |
|---|---|---|
| committer | lambda <pleromagit@rogerbraun.net> | 2018-05-18 07:51:00 +0000 |
| commit | 166d9294c477a5c5bda38dcab87d090a7a1d3486 (patch) | |
| tree | 3a8eb4f9d7a772bde855bb451d990fe448a209c2 /src/components/user_settings/user_settings.js | |
| parent | 954e6e076333e622134ad05cc51e07dcd1c940a7 (diff) | |
| parent | fed87815833bfb847be192b79782f3edca99cf5f (diff) | |
Merge branch 'feature/follows-export' into 'develop'
Adds an option to export follows (fixed)
See merge request pleroma/pleroma-fe!261
Diffstat (limited to 'src/components/user_settings/user_settings.js')
| -rw-r--r-- | src/components/user_settings/user_settings.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 25ee1f35..2c08b2f8 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -8,6 +8,7 @@ const UserSettings = { followList: null, followImportError: false, followsImported: false, + enableFollowsExport: true, uploading: [ false, false, false, false ], previews: [ null, null, null ] } @@ -137,6 +138,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(function (friendList) { + this.exportPeople(friendList, 'friends.csv') + }.bind(this)) + }, followListChange () { // eslint-disable-next-line no-undef let formData = new FormData() |
