From ab19669bf1470f1e2dfe35cb17e3f748edf4c2d2 Mon Sep 17 00:00:00 2001 From: taehoon Date: Sat, 30 Mar 2019 08:17:37 -0400 Subject: [PATCH] refactoring --- src/components/user_settings/user_settings.js | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index de8b4ebf..748f23f7 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -251,35 +251,25 @@ const UserSettings = { } }) }, + generateExportableUsersContent (users) { + // Get addresses + return users.map((user) => { + // check is it's a local user + if (user && user.is_local) { + // append the instance address + // eslint-disable-next-line no-undef + return user.screen_name + '@' + location.hostname + } + return user.screen_name + }).join('\n') + }, getFollowsContent () { return this.$store.state.api.backendInteractor.exportFriends({ id: this.$store.state.users.currentUser.id }) - .then((users) => { - // Get all the friends addresses - return users.map((user) => { - // check is it's a local user - if (user && user.is_local) { - // append the instance address - // eslint-disable-next-line no-undef - return user.screen_name + '@' + location.hostname - } - return user.screen_name - }).join('\n') - }) + .then(this.generateExportableUsersContent) }, getBlocksContent () { return this.$store.state.api.backendInteractor.fetchBlocks() - .then((users) => { - // Get all the friends addresses - return users.map((user) => { - // check is it's a local user - if (user && user.is_local) { - // append the instance address - // eslint-disable-next-line no-undef - return user.screen_name + '@' + location.hostname - } - return user.screen_name - }).join('\n') - }) + .then(this.generateExportableUsersContent) }, confirmDelete () { this.deletingAccount = true