Skip to content

Commit

Permalink
feat: improve logic to be clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Aug 31, 2020
1 parent 7386df7 commit 8c22b88
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions store/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,27 @@ export const actions = {
customBoorusManager({ state, commit }, { operation, value }) {
switch (operation) {
case 'add': {
// value: booruObj
const doesTheBooruAlreadyExist = state.custom.boorus.some(
(booruObj) => booruObj.domain === value.domain
)

if (!doesTheBooruAlreadyExist) commit('pushCustomBooruValue', value)
if (doesTheBooruAlreadyExist) {
console.debug('A booru with this domain already exists!')
return
}

commit('pushCustomBooruValue', value)
break
}

case 'remove':
// value: booruObj
commit(
'setCustomBoorus',
state.custom.boorus.filter((customBooru) => {
return customBooru.domain !== value.domain
})
)
case 'remove': {
const arrayWithoutBooru = state.custom.boorus.filter((customBooru) => {
return customBooru.domain !== value.domain
})

commit('setCustomBoorus', arrayWithoutBooru)
break
}

case 'reset':
commit('setCustomBoorus', [])
Expand Down

0 comments on commit 8c22b88

Please sign in to comment.