forked from AkkomaGang/akkoma-fe
#315 - separate export and fetch follows logic
This commit is contained in:
parent
a3a9949a21
commit
3128417176
3 changed files with 16 additions and 7 deletions
|
@ -238,9 +238,8 @@ const UserSettings = {
|
||||||
exportFollows () {
|
exportFollows () {
|
||||||
this.enableFollowsExport = false
|
this.enableFollowsExport = false
|
||||||
this.$store.state.api.backendInteractor
|
this.$store.state.api.backendInteractor
|
||||||
.fetchFriends({
|
.exportFriends({
|
||||||
id: this.$store.state.users.currentUser.id,
|
id: this.$store.state.users.currentUser.id
|
||||||
isExport: true
|
|
||||||
})
|
})
|
||||||
.then((friendList) => {
|
.then((friendList) => {
|
||||||
this.exportPeople(friendList, 'friends.csv')
|
this.exportPeople(friendList, 'friends.csv')
|
||||||
|
|
|
@ -247,14 +247,18 @@ const fetchUser = ({id, credentials}) => {
|
||||||
.then((data) => parseUser(data))
|
.then((data) => parseUser(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchFriends = ({id, page, isExport, credentials}) => {
|
const fetchFriends = ({id, page, credentials}) => {
|
||||||
let url = `${FRIENDS_URL}?user_id=${id}`
|
let url = `${FRIENDS_URL}?user_id=${id}`
|
||||||
if (page) {
|
if (page) {
|
||||||
url = url + `&page=${page}`
|
url = url + `&page=${page}`
|
||||||
}
|
}
|
||||||
if (isExport) {
|
return fetch(url, { headers: authHeaders(credentials) })
|
||||||
url = url + `&export=${isExport}`
|
.then((data) => data.json())
|
||||||
}
|
.then((data) => data.map(parseUser))
|
||||||
|
}
|
||||||
|
|
||||||
|
const exportFriends = ({id, credentials}) => {
|
||||||
|
let url = `${FRIENDS_URL}?user_id=${id}&export=true`
|
||||||
return fetch(url, { headers: authHeaders(credentials) })
|
return fetch(url, { headers: authHeaders(credentials) })
|
||||||
.then((data) => data.json())
|
.then((data) => data.json())
|
||||||
.then((data) => data.map(parseUser))
|
.then((data) => data.map(parseUser))
|
||||||
|
@ -539,6 +543,7 @@ const apiService = {
|
||||||
fetchConversation,
|
fetchConversation,
|
||||||
fetchStatus,
|
fetchStatus,
|
||||||
fetchFriends,
|
fetchFriends,
|
||||||
|
exportFriends,
|
||||||
fetchFollowers,
|
fetchFollowers,
|
||||||
followUser,
|
followUser,
|
||||||
unfollowUser,
|
unfollowUser,
|
||||||
|
|
|
@ -14,6 +14,10 @@ const backendInteractorService = (credentials) => {
|
||||||
return apiService.fetchFriends({id, page, isExport, credentials})
|
return apiService.fetchFriends({id, page, isExport, credentials})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const exportFriends = ({id}) => {
|
||||||
|
return apiService.exportFriends({id, credentials})
|
||||||
|
}
|
||||||
|
|
||||||
const fetchFollowers = ({id, page}) => {
|
const fetchFollowers = ({id, page}) => {
|
||||||
return apiService.fetchFollowers({id, page, credentials})
|
return apiService.fetchFollowers({id, page, credentials})
|
||||||
}
|
}
|
||||||
|
@ -78,6 +82,7 @@ const backendInteractorService = (credentials) => {
|
||||||
fetchStatus,
|
fetchStatus,
|
||||||
fetchConversation,
|
fetchConversation,
|
||||||
fetchFriends,
|
fetchFriends,
|
||||||
|
exportFriends,
|
||||||
fetchFollowers,
|
fetchFollowers,
|
||||||
followUser,
|
followUser,
|
||||||
unfollowUser,
|
unfollowUser,
|
||||||
|
|
Loading…
Reference in a new issue