* Loads up given states * @param {Array } states
(states)
| 1536 | * @param {Array<Location>} states |
| 1537 | */ |
| 1538 | function loadStates(states) { |
| 1539 | if (!Array.isArray(states) || !states.length) return; |
| 1540 | |
| 1541 | const backNavigation = []; |
| 1542 | const lastState = states.pop(); |
| 1543 | if (!lastState || !lastState.url) return; |
| 1544 | const { url } = lastState; |
| 1545 | const name = lastState.name || Url.basename(url) || url; |
| 1546 | let { url: lastUrl, name: lastName } = currentDir; |
| 1547 | |
| 1548 | while (states.length) { |
| 1549 | const location = states.splice(0, 1)[0]; |
| 1550 | if (!location || !location.url) { |
| 1551 | continue; |
| 1552 | } |
| 1553 | const { url, name } = location; |
| 1554 | let action; |
| 1555 | |
| 1556 | if (doesOpenLast) pushState({ name, url }); |
| 1557 | if (lastUrl && lastName) { |
| 1558 | backNavigation.push([lastUrl, lastName]); |
| 1559 | action = () => { |
| 1560 | const [url, name] = backNavigation.pop(); |
| 1561 | navigate(url, name, false); |
| 1562 | }; |
| 1563 | } |
| 1564 | pushToNavbar(name, url, action); |
| 1565 | lastUrl = url; |
| 1566 | lastName = name; |
| 1567 | } |
| 1568 | |
| 1569 | currentDir = { url: lastUrl, name: lastName }; |
| 1570 | navigate(url, name); |
| 1571 | } |
| 1572 | |
| 1573 | /** |
| 1574 | * |
no test coverage detected