Merge pull request #1396 from h3poteto/iss-1390
refs #1390 Fix list memberships parser when add or remove list member
This commit is contained in:
commit
28c7df13b3
|
@ -73,10 +73,16 @@ const actions: ActionTree<ListMembershipState, RootState> = {
|
||||||
commit(MUTATION_TYPES.CHANGE_LISTS, res.data)
|
commit(MUTATION_TYPES.CHANGE_LISTS, res.data)
|
||||||
return res.data
|
return res.data
|
||||||
},
|
},
|
||||||
changeBelongToLists: async ({ rootState, commit, state }, belongToLists: Array<Entity.List>) => {
|
changeBelongToLists: async ({ rootState, commit, state }, belongToLists: Array<string>) => {
|
||||||
// Calcurate diff
|
// Calcurate diff
|
||||||
const removedLists = lodash.difference(state.belongToLists, belongToLists)
|
const removedLists = lodash.difference(
|
||||||
const addedLists = lodash.difference(belongToLists, state.belongToLists)
|
state.belongToLists.map(l => l.id),
|
||||||
|
belongToLists
|
||||||
|
)
|
||||||
|
const addedLists = lodash.difference(
|
||||||
|
belongToLists,
|
||||||
|
state.belongToLists.map(l => l.id)
|
||||||
|
)
|
||||||
commit(MUTATION_TYPES.CHANGE_BELONG_TO_LISTS, belongToLists)
|
commit(MUTATION_TYPES.CHANGE_BELONG_TO_LISTS, belongToLists)
|
||||||
const client = generator(
|
const client = generator(
|
||||||
rootState.TimelineSpace.sns,
|
rootState.TimelineSpace.sns,
|
||||||
|
@ -85,11 +91,11 @@ const actions: ActionTree<ListMembershipState, RootState> = {
|
||||||
rootState.App.userAgent,
|
rootState.App.userAgent,
|
||||||
rootState.App.proxyConfiguration
|
rootState.App.proxyConfiguration
|
||||||
)
|
)
|
||||||
const removedPromise = removedLists.map(list => {
|
const removedPromise = removedLists.map(id => {
|
||||||
return client.deleteAccountsFromList(list.id, [state.account!.id])
|
return client.deleteAccountsFromList(id, [state.account!.id])
|
||||||
})
|
})
|
||||||
const addedPromise = addedLists.map(list => {
|
const addedPromise = addedLists.map(id => {
|
||||||
return client.addAccountsToList(list.id, [state.account!.id])
|
return client.addAccountsToList(id, [state.account!.id])
|
||||||
})
|
})
|
||||||
const res = await Promise.all(removedPromise.concat(addedPromise))
|
const res = await Promise.all(removedPromise.concat(addedPromise))
|
||||||
return res
|
return res
|
||||||
|
|
Loading…
Reference in New Issue