add “export blocks” feature

This commit is contained in:
taehoon 2019-03-30 08:14:52 -04:00
parent 13abe64f87
commit 95bc2d727b
3 changed files with 23 additions and 2 deletions

View file

@ -253,9 +253,24 @@ const UserSettings = {
},
getFollowsContent () {
return this.$store.state.api.backendInteractor.exportFriends({ id: this.$store.state.users.currentUser.id })
.then((friendList) => {
.then((users) => {
// Get all the friends addresses
return friendList.map((user) => {
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')
})
},
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

View file

@ -182,6 +182,10 @@
<p>{{$t('settings.import_blocks_from_a_csv_file')}}</p>
<Importer :submitHandler="importBlocks" :successMessage="$t('settings.blocks_imported')" :errorMessage="$t('settings.block_import_error')" />
</div>
<div class="setting-item">
<h2>{{$t('settings.block_export')}}</h2>
<Exporter :getContent="getBlocksContent" filename="blocks.csv" :exportButtonLabel="$t('settings.block_export_button')" />
</div>
</div>
<div :label="$t('settings.blocks_tab')">

View file

@ -135,6 +135,8 @@
"avatarRadius": "Avatars",
"background": "Background",
"bio": "Bio",
"block_export": "Block export",
"block_export_button": "Export your blocks to a csv file",
"block_import": "Block import",
"block_import_error": "Error importing blocks",
"blocks_imported": "Blocks imported! Processing them will take a while.",