(layout, component, path, dispatch)
| 393 | } |
| 394 | |
| 395 | function persistenceMods(layout, component, path, dispatch) { |
| 396 | const { |
| 397 | canPersist, |
| 398 | id, |
| 399 | props, |
| 400 | element, |
| 401 | persistence, |
| 402 | persisted_props, |
| 403 | persistence_type |
| 404 | } = getProps(component); |
| 405 | |
| 406 | let layoutOut = layout; |
| 407 | if (canPersist && persistence) { |
| 408 | const storage = getStore(persistence_type, dispatch); |
| 409 | const update = {}; |
| 410 | forEach( |
| 411 | persistedProp => |
| 412 | modProp( |
| 413 | getValsKey(id, persistedProp, persistence), |
| 414 | storage, |
| 415 | element, |
| 416 | props, |
| 417 | persistedProp, |
| 418 | update |
| 419 | ), |
| 420 | persisted_props |
| 421 | ); |
| 422 | |
| 423 | for (const propName in update) { |
| 424 | layoutOut = set( |
| 425 | lensPath(path.concat('props', propName)), |
| 426 | update[propName], |
| 427 | layoutOut |
| 428 | ); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | // recurse inward |
| 433 | const {children} = props; |
| 434 | if (Array.isArray(children)) { |
| 435 | children.forEach((child, i) => { |
| 436 | if (type(child) === 'Object' && child.props) { |
| 437 | layoutOut = persistenceMods( |
| 438 | layoutOut, |
| 439 | child, |
| 440 | path.concat('props', 'children', i), |
| 441 | dispatch |
| 442 | ); |
| 443 | } |
| 444 | }); |
| 445 | } else if (type(children) === 'Object' && children.props) { |
| 446 | layoutOut = persistenceMods( |
| 447 | layoutOut, |
| 448 | children, |
| 449 | path.concat('props', 'children'), |
| 450 | dispatch |
| 451 | ); |
| 452 | } |
no test coverage detected
searching dependent graphs…