From 808e1ac11cbbe6779dcaa42d5b4cdec900339ccd Mon Sep 17 00:00:00 2001 From: taehoon Date: Wed, 13 Mar 2019 13:12:56 -0400 Subject: Switch to mastoapi for updating avatar # Conflicts: # src/services/api/api.service.js --- src/components/user_settings/user_settings.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 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 e88ee612..1e2422bb 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -164,19 +164,23 @@ const UserSettings = { reader.readAsDataURL(file) }, submitAvatar (cropper, file) { - let img - if (cropper) { - img = cropper.getCroppedCanvas().toDataURL(file.type) - } else { - img = file - } + return new Promise((resolve, reject) => { + function updateAvatar (avatar) { + this.$store.state.api.backendInteractor.updateAvatar({ avatar }) + .then((user) => { + this.$store.commit('addNewUsers', [user]) + this.$store.commit('setCurrentUser', user) + resolve() + }) + .catch((err) => { + reject(new Error(this.$t('upload.error.base') + ' ' + err.message)) + }) + } - return this.$store.state.api.backendInteractor.updateAvatar({ params: { img } }).then((user) => { - if (!user.error) { - this.$store.commit('addNewUsers', [user]) - this.$store.commit('setCurrentUser', user) + if (cropper) { + cropper.getCroppedCanvas().toBlob(updateAvatar, file.type) } else { - throw new Error(this.$t('upload.error.base') + user.error) + updateAvatar(file) } }) }, -- cgit v1.2.3-70-g09d2 From 909d11825d83201bf9ff0ec9491e6361f511ca0f Mon Sep 17 00:00:00 2001 From: taehoon Date: Wed, 13 Mar 2019 13:56:28 -0400 Subject: Switch to mastoapi for updating banner --- src/components/user_settings/user_settings.js | 32 +++++++--------------- src/services/api/api.service.js | 27 +++++------------- .../backend_interactor_service.js | 2 +- 3 files changed, 18 insertions(+), 43 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 1e2422bb..bc824393 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -160,6 +160,7 @@ const UserSettings = { reader.onload = ({target}) => { const img = target.result this[slot + 'Preview'] = img + this[slot] = file } reader.readAsDataURL(file) }, @@ -190,30 +191,17 @@ const UserSettings = { submitBanner () { if (!this.bannerPreview) { return } - let banner = this.bannerPreview - // eslint-disable-next-line no-undef - let imginfo = new Image() - /* eslint-disable camelcase */ - let offset_top, offset_left, width, height - imginfo.src = banner - width = imginfo.width - height = imginfo.height - offset_top = 0 - offset_left = 0 this.bannerUploading = true - this.$store.state.api.backendInteractor.updateBanner({params: {banner, offset_top, offset_left, width, height}}).then((data) => { - if (!data.error) { - let clone = JSON.parse(JSON.stringify(this.$store.state.users.currentUser)) - clone.cover_photo = data.url - this.$store.commit('addNewUsers', [clone]) - this.$store.commit('setCurrentUser', clone) + this.$store.state.api.backendInteractor.updateBanner({banner: this.banner}) + .then((user) => { + this.$store.commit('addNewUsers', [user]) + this.$store.commit('setCurrentUser', user) this.bannerPreview = null - } else { - this.bannerUploadError = this.$t('upload.error.base') + data.error - } - this.bannerUploading = false - }) - /* eslint-enable camelcase */ + }) + .catch((err) => { + this.bannerUploadError = this.$t('upload.error.base') + ' ' + err.message + }) + .then(() => { this.bannerUploading = false }) }, submitBg () { if (!this.backgroundPreview) { return } diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 0540b2d2..eaebb3f1 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -4,7 +4,6 @@ const ALL_FOLLOWING_URL = '/api/qvitter/allfollowing' const MENTIONS_URL = '/api/statuses/mentions.json' const REGISTRATION_URL = '/api/account/register.json' const BG_UPDATE_URL = '/api/qvitter/update_background_image.json' -const BANNER_UPDATE_URL = '/api/account/update_profile_banner.json' const PROFILE_UPDATE_URL = '/api/account/update_profile.json' const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json' const QVITTER_USER_NOTIFICATIONS_READ_URL = '/api/qvitter/statuses/notifications/read.json' @@ -108,28 +107,16 @@ const updateBg = ({credentials, params}) => { }).then((data) => data.json()) } -// Params -// height -// width -// offset_left -// offset_top -// banner (base 64 encodend data url) -const updateBanner = ({credentials, params}) => { - let url = BANNER_UPDATE_URL - +const updateBanner = ({credentials, banner}) => { const form = new FormData() - - each(params, (value, key) => { - if (value) { - form.append(key, value) - } - }) - - return fetch(url, { + form.append('header', banner) + return fetch(MASTODON_PROFILE_UPDATE_URL, { headers: authHeaders(credentials), - method: 'POST', + method: 'PATCH', body: form - }).then((data) => data.json()) + }) + .then((data) => data.json()) + .then((data) => parseUser(data)) } // Params diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index 762ee08b..d61ff452 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -103,7 +103,7 @@ const backendInteractorService = (credentials) => { const register = (params) => apiService.register(params) const updateAvatar = ({avatar}) => apiService.updateAvatar({credentials, avatar}) const updateBg = ({params}) => apiService.updateBg({credentials, params}) - const updateBanner = ({params}) => apiService.updateBanner({credentials, params}) + const updateBanner = ({banner}) => apiService.updateBanner({credentials, banner}) const updateProfile = ({params}) => apiService.updateProfile({credentials, params}) const externalProfile = (profileUrl) => apiService.externalProfile({profileUrl, credentials}) -- cgit v1.2.3-70-g09d2 From e14720419f743f630eec8a671833eb08923e3dee Mon Sep 17 00:00:00 2001 From: taehoon Date: Sat, 16 Mar 2019 08:40:46 -0400 Subject: Switch to mastoapi for updating user profile --- src/components/user_settings/user_settings.js | 14 ++++++-------- src/services/api/api.service.js | 13 ++++++------- 2 files changed, 12 insertions(+), 15 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 bc824393..6b367e4f 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -110,11 +110,11 @@ const UserSettings = { }, methods: { updateProfile () { - const name = this.newName - const description = this.newBio + const note = this.newBio const locked = this.newLocked // Backend notation. /* eslint-disable camelcase */ + const display_name = this.newName const default_scope = this.newDefaultScope const no_rich_text = this.newNoRichText const hide_follows = this.hideFollows @@ -125,8 +125,8 @@ const UserSettings = { this.$store.state.api.backendInteractor .updateProfile({ params: { - name, - description, + display_name, + note, locked, // Backend notation. /* eslint-disable camelcase */ @@ -137,10 +137,8 @@ const UserSettings = { show_role /* eslint-enable camelcase */ }}).then((user) => { - if (!user.error) { - this.$store.commit('addNewUsers', [user]) - this.$store.commit('setCurrentUser', user) - } + this.$store.commit('addNewUsers', [user]) + this.$store.commit('setCurrentUser', user) }) }, changeVis (visibility) { diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index eaebb3f1..9338c495 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -4,7 +4,6 @@ const ALL_FOLLOWING_URL = '/api/qvitter/allfollowing' const MENTIONS_URL = '/api/statuses/mentions.json' const REGISTRATION_URL = '/api/account/register.json' const BG_UPDATE_URL = '/api/qvitter/update_background_image.json' -const PROFILE_UPDATE_URL = '/api/account/update_profile.json' const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json' const QVITTER_USER_NOTIFICATIONS_READ_URL = '/api/qvitter/statuses/notifications/read.json' const FOLLOW_IMPORT_URL = '/api/pleroma/follow_import' @@ -126,9 +125,7 @@ const updateBanner = ({credentials, banner}) => { // description const updateProfile = ({credentials, params}) => { // Always include these fields, because they might be empty or false - const fields = ['description', 'locked', 'no_rich_text', 'hide_follows', 'hide_followers', 'show_role'] - let url = PROFILE_UPDATE_URL - + const fields = ['note', 'locked', 'no_rich_text', 'hide_follows', 'hide_followers', 'show_role'] const form = new FormData() each(params, (value, key) => { @@ -136,11 +133,13 @@ const updateProfile = ({credentials, params}) => { form.append(key, value) } }) - return fetch(url, { + return fetch(MASTODON_PROFILE_UPDATE_URL, { headers: authHeaders(credentials), - method: 'POST', + method: 'PATCH', body: form - }).then((data) => data.json()) + }) + .then((data) => data.json()) + .then((data) => parseUser(data)) } // Params needed: -- cgit v1.2.3-70-g09d2 From ac0b45fa149dad9be84074313b69b9f3d360928a Mon Sep 17 00:00:00 2001 From: taehoon Date: Fri, 22 Mar 2019 13:00:58 -0400 Subject: Update avatar uploading --- src/components/image_cropper/image_cropper.js | 16 ++-------------- src/components/image_cropper/image_cropper.vue | 4 ++-- src/components/user_settings/user_settings.js | 9 +++++---- 3 files changed, 9 insertions(+), 20 deletions(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/image_cropper/image_cropper.js b/src/components/image_cropper/image_cropper.js index 5ba8f04e..01361e25 100644 --- a/src/components/image_cropper/image_cropper.js +++ b/src/components/image_cropper/image_cropper.js @@ -70,22 +70,10 @@ const ImageCropper = { this.dataUrl = undefined this.$emit('close') }, - submit () { + submit (cropping = true) { this.submitting = true this.avatarUploadError = null - this.submitHandler(this.cropper, this.file) - .then(() => this.destroy()) - .catch((err) => { - this.submitError = err - }) - .finally(() => { - this.submitting = false - }) - }, - submitWithoutCropping () { - this.submitting = true - this.avatarUploadError = null - this.submitHandler(false, this.dataUrl) + this.submitHandler(cropping && this.cropper, this.file) .then(() => this.destroy()) .catch((err) => { this.submitError = err diff --git a/src/components/image_cropper/image_cropper.vue b/src/components/image_cropper/image_cropper.vue index 129e6f46..d2b86e9e 100644 --- a/src/components/image_cropper/image_cropper.vue +++ b/src/components/image_cropper/image_cropper.vue @@ -5,9 +5,9 @@
- + - +
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 6b367e4f..820feba6 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -163,16 +163,17 @@ const UserSettings = { reader.readAsDataURL(file) }, submitAvatar (cropper, file) { + const that = this return new Promise((resolve, reject) => { function updateAvatar (avatar) { - this.$store.state.api.backendInteractor.updateAvatar({ avatar }) + that.$store.state.api.backendInteractor.updateAvatar({ avatar }) .then((user) => { - this.$store.commit('addNewUsers', [user]) - this.$store.commit('setCurrentUser', user) + that.$store.commit('addNewUsers', [user]) + that.$store.commit('setCurrentUser', user) resolve() }) .catch((err) => { - reject(new Error(this.$t('upload.error.base') + ' ' + err.message)) + reject(new Error(that.$t('upload.error.base') + ' ' + err.message)) }) } -- cgit v1.2.3-70-g09d2 From 562120ae48945d87a24f2248f9b16185b49159d0 Mon Sep 17 00:00:00 2001 From: taehoon Date: Fri, 29 Mar 2019 21:58:20 -0400 Subject: split out follow’s importer as a separate component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/importer/importer.js | 36 ++++++++++++++++++++++++++ src/components/importer/importer.vue | 19 ++++++++++++++ src/components/user_settings/user_settings.js | 31 +++------------------- src/components/user_settings/user_settings.vue | 14 +--------- 4 files changed, 59 insertions(+), 41 deletions(-) create mode 100644 src/components/importer/importer.js create mode 100644 src/components/importer/importer.vue (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/importer/importer.js b/src/components/importer/importer.js new file mode 100644 index 00000000..8d6c8b3f --- /dev/null +++ b/src/components/importer/importer.js @@ -0,0 +1,36 @@ +const Importer = { + data () { + return { + file: null, + error: false, + success: false, + uploading: false + } + }, + methods: { + change () { + this.file = this.$refs.input.files[0] + }, + submit () { + this.uploading = true + // eslint-disable-next-line no-undef + const formData = new FormData() + formData.append('list', this.file) + this.$store.state.api.backendInteractor.followImport({params: formData}) + .then((status) => { + if (status) { + this.success = true + } else { + this.error = true + } + this.uploading = false + }) + }, + dismiss () { + this.success = false + this.error = false + } + } +} + +export default Importer diff --git a/src/components/importer/importer.vue b/src/components/importer/importer.vue new file mode 100644 index 00000000..0fd83b7c --- /dev/null +++ b/src/components/importer/importer.vue @@ -0,0 +1,19 @@ + + + diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index e88ee612..a213650b 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -13,6 +13,7 @@ import SelectableList from '../selectable_list/selectable_list.vue' import ProgressButton from '../progress_button/progress_button.vue' import EmojiInput from '../emoji-input/emoji-input.vue' import Autosuggest from '../autosuggest/autosuggest.vue' +import Importer from '../importer/importer.vue' import withSubscription from '../../hocs/with_subscription/with_subscription' import userSearchApi from '../../services/new_api/user_search.js' @@ -40,14 +41,10 @@ const UserSettings = { hideFollowers: this.$store.state.users.currentUser.hide_followers, showRole: this.$store.state.users.currentUser.show_role, role: this.$store.state.users.currentUser.role, - followList: null, - followImportError: false, - followsImported: false, enableFollowsExport: true, pickAvatarBtnVisible: true, bannerUploading: false, backgroundUploading: false, - followListUploading: false, bannerPreview: null, backgroundPreview: null, bannerUploadError: null, @@ -75,7 +72,8 @@ const UserSettings = { Autosuggest, BlockCard, MuteCard, - ProgressButton + ProgressButton, + Importer }, computed: { user () { @@ -236,19 +234,6 @@ const UserSettings = { this.backgroundUploading = false }) }, - importFollows () { - this.followListUploading = true - const followList = this.followList - this.$store.state.api.backendInteractor.followImport({params: followList}) - .then((status) => { - if (status) { - this.followsImported = true - } else { - this.followImportError = true - } - this.followListUploading = false - }) - }, /* This function takes an Array of Users * and outputs a file with all the addresses for the user to download */ @@ -283,16 +268,6 @@ const UserSettings = { setTimeout(() => { this.enableFollowsExport = true }, 2000) }) }, - followListChange () { - // eslint-disable-next-line no-undef - let formData = new FormData() - formData.append('list', this.$refs.followlist.files[0]) - this.followList = formData - }, - dismissImported () { - this.followsImported = false - this.followImportError = false - }, confirmDelete () { this.deletingAccount = true }, diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue index d68e68fa..fb91e269 100644 --- a/src/components/user_settings/user_settings.vue +++ b/src/components/user_settings/user_settings.vue @@ -171,19 +171,7 @@

{{$t('settings.follow_import')}}

{{$t('settings.import_followers_from_a_csv_file')}}

-
- -
- - -
- -

{{$t('settings.follows_imported')}}

-
-
- -

{{$t('settings.follow_import_error')}}

-
+

{{$t('settings.follow_export')}}

-- cgit v1.2.3-70-g09d2 From 6d0e98a1c2c81c587b89736dbd2ac43a8c540d54 Mon Sep 17 00:00:00 2001 From: taehoon Date: Sat, 30 Mar 2019 05:10:57 -0400 Subject: make Importer component reusable --- src/components/importer/importer.js | 42 +++++++++++++++++++------- src/components/importer/importer.vue | 10 +++--- src/components/user_settings/user_settings.js | 8 +++++ src/components/user_settings/user_settings.vue | 2 +- src/i18n/en.json | 5 +++ 5 files changed, 50 insertions(+), 17 deletions(-) (limited to 'src/components/user_settings/user_settings.js') diff --git a/src/components/importer/importer.js b/src/components/importer/importer.js index 44d02c93..c5f9e4d2 100644 --- a/src/components/importer/importer.js +++ b/src/components/importer/importer.js @@ -1,10 +1,34 @@ const Importer = { + props: { + submitHandler: { + type: Function, + required: true + }, + submitButtonLabel: { + type: String, + default () { + return this.$t('importer.submit') + } + }, + successMessage: { + type: String, + default () { + return this.$t('importer.success') + } + }, + errorMessage: { + type: String, + default () { + return this.$t('importer.error') + } + } + }, data () { return { file: null, error: false, success: false, - uploading: false + submitting: false } }, methods: { @@ -12,16 +36,12 @@ const Importer = { this.file = this.$refs.input.files[0] }, submit () { - this.uploading = true - this.$store.state.api.backendInteractor.followImport(this.file) - .then((status) => { - if (status) { - this.success = true - } else { - this.error = true - } - this.uploading = false - }) + this.dismiss() + this.submitting = true + this.submitHandler(this.file) + .then(() => { this.success = true }) + .catch(() => { this.error = true }) + .finally(() => { this.submitting = false }) }, dismiss () { this.success = false diff --git a/src/components/importer/importer.vue b/src/components/importer/importer.vue index d2447e1a..0c5aa93d 100644 --- a/src/components/importer/importer.vue +++ b/src/components/importer/importer.vue @@ -3,15 +3,15 @@
- - + +
-

{{$t('settings.follows_imported')}}

+

{{successMessage}}

-

{{$t('settings.follow_import_error')}}

+

{{errorMessage}}

@@ -20,7 +20,7 @@ diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index c4214744..d40301f2 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -14,6 +14,7 @@ import ProgressButton from '../progress_button/progress_button.vue' import EmojiInput from '../emoji-input/emoji-input.vue' import Autosuggest from '../autosuggest/autosuggest.vue' import Importer from '../importer/importer.vue' +import Exporter from '../exporter/exporter.vue' import withSubscription from '../../hocs/with_subscription/with_subscription' import userSearchApi from '../../services/new_api/user_search.js' @@ -41,7 +42,6 @@ const UserSettings = { hideFollowers: this.$store.state.users.currentUser.hide_followers, showRole: this.$store.state.users.currentUser.show_role, role: this.$store.state.users.currentUser.role, - enableFollowsExport: true, pickAvatarBtnVisible: true, bannerUploading: false, backgroundUploading: false, @@ -73,7 +73,8 @@ const UserSettings = { BlockCard, MuteCard, ProgressButton, - Importer + Importer, + Exporter }, computed: { user () { @@ -250,38 +251,19 @@ const UserSettings = { } }) }, - /* 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 - .exportFriends({ - id: this.$store.state.users.currentUser.id - }) + getFollowsContent () { + return this.$store.state.api.backendInteractor.exportFriends({ id: this.$store.state.users.currentUser.id }) .then((friendList) => { - this.exportPeople(friendList, 'friends.csv') - setTimeout(() => { this.enableFollowsExport = true }, 2000) + // Get all the friends addresses + return friendList.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') }) }, confirmDelete () { diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue index 520a3d8a..ef77aaba 100644 --- a/src/components/user_settings/user_settings.vue +++ b/src/components/user_settings/user_settings.vue @@ -173,12 +173,9 @@

{{$t('settings.import_followers_from_a_csv_file')}}

-
+

{{$t('settings.follow_export')}}

- -
-
-

{{$t('settings.follow_export_processing')}}

+

{{$t('settings.block_import')}}

diff --git a/src/i18n/en.json b/src/i18n/en.json index d4ec1134..10283024 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -2,6 +2,10 @@ "chat": { "title": "Chat" }, + "exporter": { + "export": "Export", + "processing": "Processing, you'll soon be asked to download your file" + }, "features_panel": { "chat": "Chat", "gopher": "Gopher", @@ -161,7 +165,6 @@ "filtering_explanation": "All statuses containing these words will be muted, one per line", "follow_export": "Follow export", "follow_export_button": "Export your follows to a csv file", - "follow_export_processing": "Processing, you'll soon be asked to download your file", "follow_import": "Follow import", "follow_import_error": "Error importing followers", "follows_imported": "Follows imported! Processing them will take a while.", -- cgit v1.2.3-70-g09d2 From 95bc2d727b8a94e9050a71c27838eb2a0d765011 Mon Sep 17 00:00:00 2001 From: taehoon Date: Sat, 30 Mar 2019 08:14:52 -0400 Subject: add “export blocks” feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/user_settings/user_settings.js | 19 +++++++++++++++++-- src/components/user_settings/user_settings.vue | 4 ++++ src/i18n/en.json | 2 ++ 3 files changed, 23 insertions(+), 2 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 d40301f2..de8b4ebf 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -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 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 friendList.map((user) => { + return users.map((user) => { // check is it's a local user if (user && user.is_local) { // append the instance address diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue index db8c1ea9..8a94f0b8 100644 --- a/src/components/user_settings/user_settings.vue +++ b/src/components/user_settings/user_settings.vue @@ -182,6 +182,10 @@

{{$t('settings.import_blocks_from_a_csv_file')}}

+
+

{{$t('settings.block_export')}}

+ +
diff --git a/src/i18n/en.json b/src/i18n/en.json index 10283024..173e0de2 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -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.", -- cgit v1.2.3-70-g09d2 From ab19669bf1470f1e2dfe35cb17e3f748edf4c2d2 Mon Sep 17 00:00:00 2001 From: taehoon Date: Sat, 30 Mar 2019 08:17:37 -0400 Subject: refactoring --- src/components/user_settings/user_settings.js | 38 ++++++++++----------------- 1 file changed, 14 insertions(+), 24 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 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 -- cgit v1.2.3-70-g09d2 From 2c4af6693ac87f5008566b6d9a61e9b4c9b3bdd8 Mon Sep 17 00:00:00 2001 From: taehoon Date: Sat, 27 Apr 2019 14:04:30 -0400 Subject: clean up --- src/components/user_settings/user_settings.js | 30 +++++++++------------------ 1 file changed, 10 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 820feba6..ae4d0694 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -110,31 +110,21 @@ const UserSettings = { }, methods: { updateProfile () { - const note = this.newBio - const locked = this.newLocked - // Backend notation. - /* eslint-disable camelcase */ - const display_name = this.newName - const default_scope = this.newDefaultScope - const no_rich_text = this.newNoRichText - const hide_follows = this.hideFollows - const hide_followers = this.hideFollowers - const show_role = this.showRole - - /* eslint-enable camelcase */ this.$store.state.api.backendInteractor .updateProfile({ params: { - display_name, - note, - locked, + note: this.newBio, + locked: this.newLocked, + source: { + privacy: this.newDefaultScope + }, // Backend notation. /* eslint-disable camelcase */ - default_scope, - no_rich_text, - hide_follows, - hide_followers, - show_role + display_name: this.newName, + no_rich_text: this.newNoRichText, + hide_follows: this.hideFollows, + hide_followers: this.hideFollowers, + show_role: this.showRole /* eslint-enable camelcase */ }}).then((user) => { this.$store.commit('addNewUsers', [user]) -- cgit v1.2.3-70-g09d2 From 3665c86d709f3a04ae3471d09b84a69c8a8c9172 Mon Sep 17 00:00:00 2001 From: taehoon Date: Sat, 27 Apr 2019 21:51:17 -0400 Subject: use default_scope parameter --- src/components/user_settings/user_settings.js | 4 +--- 1 file changed, 1 insertion(+), 3 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 ae4d0694..5a7ff448 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -115,12 +115,10 @@ const UserSettings = { params: { note: this.newBio, locked: this.newLocked, - source: { - privacy: this.newDefaultScope - }, // Backend notation. /* eslint-disable camelcase */ display_name: this.newName, + default_scope: this.newDefaultScope, no_rich_text: this.newNoRichText, hide_follows: this.hideFollows, hide_followers: this.hideFollowers, -- cgit v1.2.3-70-g09d2