From fed87815833bfb847be192b79782f3edca99cf5f Mon Sep 17 00:00:00 2001 From: aka Date: Wed, 16 May 2018 19:51:52 -0300 Subject: fix linting --- src/components/user_settings/user_settings.js | 43 ++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 602052ca..2c08b2f8 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -141,30 +141,33 @@ const UserSettings = { /* This function takes an Array of Users * and outputs a file with all the addresses for the user to download */ - exportPeople(Users) { + 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 - user.screen_name += '@' + location.hostname; - } - return user.screen_name; - }).join('\n'); + 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', 'friends.csv'); - fileToDownload.style.display = 'none'; - document.body.appendChild(fileToDownload); - fileToDownload.click(); - document.body.removeChild(fileToDownload); + 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; + exportFollows () { + this.enableFollowsExport = false this.$store.state.api.backendInteractor - .fetchFriends({id: this.$store.state.users.currentUser.id}) - .then(this.exportPeople); + .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 -- cgit v1.2.3-70-g09d2