From 27cbe3ca658e3f9a40650f119854cd7d31094085 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 12 Mar 2019 22:10:22 +0200 Subject: [PATCH] =?UTF-8?q?=E3=83=AC=E3=82=A4=E3=83=B3=E3=81=9B=E3=82=93?= =?UTF-8?q?=E3=81=B1=E3=81=84=E3=81=AB=E3=82=B5=E3=83=B3=E3=82=AD=E3=83=A5?= =?UTF-8?q?=E3=83=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/user_profile/user_profile.js | 7 ++++--- src/modules/users.js | 10 ++++------ src/services/api/api.service.js | 18 ------------------ .../backend_interactor_service.js | 5 ----- 4 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index a8dfce2f..216ac392 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -100,9 +100,10 @@ const UserProfile = { if (this.userId && !this.$route.params.name) { fetchPromise = this.$store.dispatch('fetchUser', this.userId) } else { - fetchPromise = this.$store.dispatch('fetchUserByScreenName', this.userName) - .then(userId => { - this.fetchedUserId = userId + fetchPromise = this.$store.dispatch('fetchUser', this.userName) + .then(({ id }) => { + console.log(arguments) + this.fetchedUserId = id }) } return fetchPromise diff --git a/src/modules/users.js b/src/modules/users.js index d04c7f0b..27114684 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -152,12 +152,10 @@ const users = { actions: { fetchUser (store, id) { return store.rootState.api.backendInteractor.fetchUser({ id }) - .then((user) => store.commit('addNewUsers', [user])) - }, - fetchUserByScreenName (store, screenName) { - return store.rootState.api.backendInteractor.figureOutUserId({ screenName }) - .then((qvitterUserData) => store.rootState.api.backendInteractor.fetchUser({ id: qvitterUserData.id })) - .then((user) => store.commit('addNewUsers', [user]) || user.id) + .then((user) => { + store.commit('addNewUsers', [user]) + return user + }) }, fetchUserRelationship (store, id) { return store.rootState.api.backendInteractor.fetchUserRelationship({ id }) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 5a0aa2de..1c6703b7 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -32,7 +32,6 @@ const QVITTER_USER_NOTIFICATIONS_URL = '/api/qvitter/statuses/notifications.json const QVITTER_USER_NOTIFICATIONS_READ_URL = '/api/qvitter/statuses/notifications/read.json' const BLOCKING_URL = '/api/blocks/create.json' const UNBLOCKING_URL = '/api/blocks/destroy.json' -const USER_URL = '/api/users/show.json' const FOLLOW_IMPORT_URL = '/api/pleroma/follow_import' const DELETE_ACCOUNT_URL = '/api/pleroma/delete_account' const CHANGE_PASSWORD_URL = '/api/pleroma/change_password' @@ -273,22 +272,6 @@ const fetchUserRelationship = ({id, credentials}) => { }) } -// TODO remove once MastoAPI supports screen_name in fetchUser one -const figureOutUserId = ({screenName, credentials}) => { - let url = `${USER_URL}/?user_id=${screenName}` - return fetch(url, { headers: authHeaders(credentials) }) - .then((response) => { - return new Promise((resolve, reject) => response.json() - .then((json) => { - if (!response.ok) { - return reject(new StatusCodeError(response.status, json, { url }, response)) - } - return resolve(json) - })) - }) - .then((data) => parseUser(data)) -} - const fetchFriends = ({id, page, credentials}) => { let url = `${FRIENDS_URL}?user_id=${id}` if (page) { @@ -622,7 +605,6 @@ const apiService = { unblockUser, fetchUser, fetchUserRelationship, - figureOutUserId, favorite, unfavorite, retweet, diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index 48689167..cbd0b733 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -26,10 +26,6 @@ const backendInteractorService = (credentials) => { return apiService.fetchAllFollowing({username, credentials}) } - const figureOutUserId = ({screenName}) => { - return apiService.figureOutUserId({screenName, credentials}) - } - const fetchUser = ({id}) => { return apiService.fetchUser({id, credentials}) } @@ -99,7 +95,6 @@ const backendInteractorService = (credentials) => { unfollowUser, blockUser, unblockUser, - figureOutUserId, fetchUser, fetchUserRelationship, fetchAllFollowing,