forked from AkkomaGang/akkoma-fe
Commit list accounts state after difference in removed accounts is determined (#82)
Reviewed-on: AkkomaGang/pleroma-fe#82 Co-authored-by: Yukkuri <iamtakingiteasy@eientei.org> Co-committed-by: Yukkuri <iamtakingiteasy@eientei.org>
This commit is contained in:
parent
7c675f1ded
commit
f474763151
1 changed files with 10 additions and 6 deletions
|
@ -57,12 +57,16 @@ const actions = {
|
||||||
commit('setList', { id, title })
|
commit('setList', { id, title })
|
||||||
},
|
},
|
||||||
setListAccounts ({ rootState, commit }, { id, accountIds }) {
|
setListAccounts ({ rootState, commit }, { id, accountIds }) {
|
||||||
|
const saved = rootState.lists.allListsObject[id].accountIds
|
||||||
|
const added = accountIds.filter(id => !saved.includes(id))
|
||||||
|
const removed = saved.filter(id => !accountIds.includes(id))
|
||||||
commit('setListAccounts', { id, accountIds })
|
commit('setListAccounts', { id, accountIds })
|
||||||
rootState.api.backendInteractor.addAccountsToList({ id, accountIds })
|
if (added.length > 0) {
|
||||||
rootState.api.backendInteractor.removeAccountsFromList({
|
rootState.api.backendInteractor.addAccountsToList({ id, accountIds: added })
|
||||||
id,
|
}
|
||||||
accountIds: rootState.lists.allListsObject[id].accountIds.filter(id => !accountIds.includes(id))
|
if (removed.length > 0) {
|
||||||
})
|
rootState.api.backendInteractor.removeAccountsFromList({ id, accountIds: removed })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
deleteList ({ rootState, commit }, { id }) {
|
deleteList ({ rootState, commit }, { id }) {
|
||||||
rootState.api.backendInteractor.deleteList({ id })
|
rootState.api.backendInteractor.deleteList({ id })
|
||||||
|
@ -76,7 +80,7 @@ export const getters = {
|
||||||
return state.allListsObject[id].title
|
return state.allListsObject[id].title
|
||||||
},
|
},
|
||||||
findListAccounts: state => id => {
|
findListAccounts: state => id => {
|
||||||
return state.allListsObject[id].accountIds
|
return [...state.allListsObject[id].accountIds]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue