chore: use argument deconstruction
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
parent
f3c5bbce5a
commit
76314e333c
|
@ -85,46 +85,46 @@ export const store = createStore({
|
|||
},
|
||||
},
|
||||
actions: {
|
||||
[CURRENT_LIST](ctx, currentList) {
|
||||
[CURRENT_LIST]({state, commit}, currentList) {
|
||||
|
||||
if (currentList === null) {
|
||||
ctx.commit(CURRENT_LIST, {})
|
||||
ctx.commit(BACKGROUND, null)
|
||||
commit(CURRENT_LIST, {})
|
||||
commit(BACKGROUND, null)
|
||||
return
|
||||
}
|
||||
|
||||
// Not sure if this is the right way to do it but hey, it works
|
||||
if (
|
||||
// List changed
|
||||
currentList.id !== ctx.state.currentList.id ||
|
||||
currentList.id !== state.currentList.id ||
|
||||
// The current list got a new background and didn't have one previously
|
||||
(
|
||||
currentList.backgroundInformation &&
|
||||
!ctx.state.currentList.backgroundInformation
|
||||
!state.currentList.backgroundInformation
|
||||
) ||
|
||||
// The current list got a new background and had one previously
|
||||
(
|
||||
currentList.backgroundInformation &&
|
||||
currentList.backgroundInformation.unsplashId &&
|
||||
ctx.state.currentList &&
|
||||
ctx.state.currentList.backgroundInformation &&
|
||||
ctx.state.currentList.backgroundInformation.unsplashId &&
|
||||
currentList.backgroundInformation.unsplashId !== ctx.state.currentList.backgroundInformation.unsplashId
|
||||
state.currentList &&
|
||||
state.currentList.backgroundInformation &&
|
||||
state.currentList.backgroundInformation.unsplashId &&
|
||||
currentList.backgroundInformation.unsplashId !== state.currentList.backgroundInformation.unsplashId
|
||||
) ||
|
||||
// The new list has a background which is not an unsplash one and did not have one previously
|
||||
(
|
||||
currentList.backgroundInformation &&
|
||||
currentList.backgroundInformation.type &&
|
||||
ctx.state.currentList &&
|
||||
ctx.state.currentList.backgroundInformation &&
|
||||
ctx.state.currentList.backgroundInformation.type
|
||||
state.currentList &&
|
||||
state.currentList.backgroundInformation &&
|
||||
state.currentList.backgroundInformation.type
|
||||
)
|
||||
) {
|
||||
if (currentList.backgroundInformation) {
|
||||
const listService = new ListService()
|
||||
listService.background(currentList)
|
||||
.then(b => {
|
||||
ctx.commit(BACKGROUND, b)
|
||||
commit(BACKGROUND, b)
|
||||
})
|
||||
.catch(e => {
|
||||
console.error('Error getting background image for list', currentList.id, e)
|
||||
|
@ -133,16 +133,16 @@ export const store = createStore({
|
|||
}
|
||||
|
||||
if (typeof currentList.backgroundInformation === 'undefined' || currentList.backgroundInformation === null) {
|
||||
ctx.commit(BACKGROUND, null)
|
||||
commit(BACKGROUND, null)
|
||||
}
|
||||
|
||||
// Server updates don't return the right. Therefore the right is reset after updating the list which is
|
||||
// confusing because all the buttons will disappear in that case. To prevent this, we're keeping the right
|
||||
// when updating the list in global state.
|
||||
if (typeof ctx.state.currentList.maxRight !== 'undefined' && (typeof currentList.maxRight === 'undefined' || currentList.maxRight === null)) {
|
||||
currentList.maxRight = ctx.state.currentList.maxRight
|
||||
if (typeof state.currentList.maxRight !== 'undefined' && (typeof currentList.maxRight === 'undefined' || currentList.maxRight === null)) {
|
||||
currentList.maxRight = state.currentList.maxRight
|
||||
}
|
||||
ctx.commit(CURRENT_LIST, currentList)
|
||||
commit(CURRENT_LIST, currentList)
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
Reference in New Issue
Block a user