refactor: don't make API calls directly

This commit is contained in:
Sol Fisher Romanoff 2022-06-18 16:04:18 +03:00
parent 9217ca8476
commit a6136f6cb2
No known key found for this signature in database
GPG key ID: 9D3F2B64F2341B62
8 changed files with 115 additions and 47 deletions

View file

@ -41,8 +41,7 @@ const ListNew = {
}
},
...mapState({
currentUser: state => state.users.currentUser,
backendInteractor: state => state.api.backendInteractor
currentUser: state => state.users.currentUser
}),
...mapGetters(['findUser'])
},
@ -86,12 +85,10 @@ const ListNew = {
createList () {
// the API has two different endpoints for "creating a list with a name"
// and "updating the accounts on the list".
this.$store.state.api.backendInteractor.createList({ title: this.title })
.then((data) => {
this.$store.state.api.backendInteractor.addAccountsToList({
id: data.id, accountIds: this.selectedUserIds
})
this.$router.push({ name: 'list-timeline', params: { id: data.id } })
this.$store.dispatch('createList', { title: this.title })
.then((list) => {
this.$store.dispatch('setListAccounts', { id: list.id, accountIds: this.selectedUserIds })
this.$router.push({ name: 'list-timeline', params: { id: list.id } })
})
}
}