This commit is contained in:
Hakaba Hitoyo 2018-08-02 18:34:12 +09:00
parent bcd499c372
commit 5900bccff3
2 changed files with 16 additions and 13 deletions

View file

@ -1,4 +1,6 @@
function showWhoToFollow (panel, reply, aHost, aUser) { import apiService from '../../services/api/api.service.js'
function showWhoToFollow (panel, reply) {
var users = reply.ids var users = reply.ids
var cn var cn
var index = 0 var index = 0
@ -58,16 +60,9 @@ function getWhoToFollow (panel) {
panel.name2 = 'Loading...' panel.name2 = 'Loading...'
panel.name3 = 'Loading...' panel.name3 = 'Loading...'
var url = '/api/v1/suggestions' var url = '/api/v1/suggestions'
window.fetch(url, {headers: authHeaders(credentials)}).then(function (response) { apiService.suggestions ({credentials: credentials})
if (response.ok) { .then ((reply) => {
return response.json() showWhoToFollow(panel, reply)
} else {
panel.name1 = ''
panel.name2 = ''
panel.name3 = ''
}
}).then(function (reply) {
showWhoToFollow(panel, reply, host, user)
}) })
} }
} }

View file

@ -36,6 +36,7 @@ const CHANGE_PASSWORD_URL = '/api/pleroma/change_password'
const FOLLOW_REQUESTS_URL = '/api/pleroma/friend_requests' const FOLLOW_REQUESTS_URL = '/api/pleroma/friend_requests'
const APPROVE_USER_URL = '/api/pleroma/friendships/approve' const APPROVE_USER_URL = '/api/pleroma/friendships/approve'
const DENY_USER_URL = '/api/pleroma/friendships/deny' const DENY_USER_URL = '/api/pleroma/friendships/deny'
const SUGGESTIONS_URL = '/api/v1/suggestions'
import { each, map } from 'lodash' import { each, map } from 'lodash'
import 'whatwg-fetch' import 'whatwg-fetch'
@ -448,6 +449,12 @@ const fetchMutes = ({credentials}) => {
}).then((data) => data.json()) }).then((data) => data.json())
} }
const suggestions = ({credentials}) => {
return fetch(SUGGESTIONS_URL, {
headers: authHeaders(credentials)
}).then((data) => data.json())
}
const apiService = { const apiService = {
verifyCredentials, verifyCredentials,
fetchTimeline, fetchTimeline,
@ -481,7 +488,8 @@ const apiService = {
changePassword, changePassword,
fetchFollowRequests, fetchFollowRequests,
approveUser, approveUser,
denyUser denyUser,
suggestions
} }
export default apiService export default apiService