codingblocks/qit.cloud

View on GitHub
website/src/hooks/saveQueueHook.js

Summary

Maintainability
A
25 mins
Test Coverage
import mirror from 'mirrorx'
 
Function `eventTracking` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
export const eventTracking = mirror.hook((action, getState) => {
const queue = getState().player.queue
 
if (action.type.startsWith('player')) {
if (action.type === 'player/removeFromQueue' && queue.length === 0) {
return window.localStorage.setItem('queue', '[]')
}
 
if (queue.length > 0) {
window.localStorage.setItem('queue', JSON.stringify(queue))
}
}
})