forked from AkkomaGang/akkoma-fe
Allow removing accounts from list
This commit is contained in:
parent
dea803468f
commit
92fac1cd9f
2 changed files with 24 additions and 4 deletions
|
@ -94,11 +94,18 @@ const ListNew = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateList () {
|
updateList () {
|
||||||
// the API has two different endpoints for "updating the list name" and
|
// the API has three different endpoints: one for "updating the list name",
|
||||||
// "updating the accounts on the list".
|
// one for "adding new accounts to the list" and one for "removing
|
||||||
|
// accounts from the list".
|
||||||
this.$store.state.api.backendInteractor.updateList({ id: this.id, title: this.title })
|
this.$store.state.api.backendInteractor.updateList({ id: this.id, title: this.title })
|
||||||
this.$store.state.api.backendInteractor.addAccountsToList({
|
this.$store.state.api.backendInteractor.addAccountsToList({
|
||||||
id: this.id, accountIds: this.selectedUserIds
|
id: this.id, accountIds: this.selectedUserIds
|
||||||
|
})
|
||||||
|
this.$store.state.api.backendInteractor.getListAccounts({ id: this.id })
|
||||||
|
.then((data) => {
|
||||||
|
this.$store.state.api.backendInteractor.removeAccountsFromList({
|
||||||
|
id: this.id, accountIds: data.filter(x => !this.selectedUserIds.includes(x))
|
||||||
|
})
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$router.push({ name: 'list-timeline', params: { id: this.id } })
|
this.$router.push({ name: 'list-timeline', params: { id: this.id } })
|
||||||
})
|
})
|
||||||
|
|
|
@ -441,6 +441,18 @@ const addAccountsToList = ({ id, accountIds, credentials }) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const removeAccountsFromList = ({ id, accountIds, credentials }) => {
|
||||||
|
const url = MASTODON_LIST_ACCOUNTS_URL(id)
|
||||||
|
const headers = authHeaders(credentials)
|
||||||
|
headers['Content-Type'] = 'application/json'
|
||||||
|
|
||||||
|
return fetch(url, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: headers,
|
||||||
|
body: JSON.stringify({ account_ids: accountIds })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const deleteList = ({ id, credentials }) => {
|
const deleteList = ({ id, credentials }) => {
|
||||||
const url = MASTODON_LIST_URL(id)
|
const url = MASTODON_LIST_URL(id)
|
||||||
return fetch(url, {
|
return fetch(url, {
|
||||||
|
@ -1427,6 +1439,7 @@ const apiService = {
|
||||||
updateList,
|
updateList,
|
||||||
getListAccounts,
|
getListAccounts,
|
||||||
addAccountsToList,
|
addAccountsToList,
|
||||||
|
removeAccountsFromList,
|
||||||
deleteList,
|
deleteList,
|
||||||
approveUser,
|
approveUser,
|
||||||
denyUser,
|
denyUser,
|
||||||
|
|
Loading…
Reference in a new issue