()
| 1359 | |
| 1360 | // -------------------- defaults + layout -------------------- |
| 1361 | function applyUserLayoutOrDefault() { |
| 1362 | const layout = readLayout(); |
| 1363 | const hasAny = Object.keys(layout).length > 0; |
| 1364 | |
| 1365 | if (hasAny) { |
| 1366 | const placed = new Set(); |
| 1367 | if (!isSmallScreen()) { |
| 1368 | ORDER_TRACKED_ZONES.forEach(zoneId => applyZoneOrder(layout, zoneId, placed)); |
| 1369 | } |
| 1370 | |
| 1371 | getCards().forEach(card => { |
| 1372 | const targetZone = layout[card.id]; |
| 1373 | if (!targetZone) return; |
| 1374 | if (placed.has(card.id)) return; |
| 1375 | // On small screens: if saved zone is the sidebar, temporarily place in top cols |
| 1376 | if (isSmallScreen() && targetZone === ZONES.SIDEBAR) { |
| 1377 | const target = (card.id === 'uploadCard') ? ZONES.TOP_LEFT : ZONES.TOP_RIGHT; |
| 1378 | placeCardInZone(card, target, { animate: false }); |
| 1379 | } else { |
| 1380 | placeCardInZone(card, targetZone, { animate: false }); |
| 1381 | } |
| 1382 | }); |
| 1383 | updateTopZoneLayout(); |
| 1384 | updateSidebarVisibility(); |
| 1385 | return; |
| 1386 | } |
| 1387 | |
| 1388 | // No saved layout yet: apply defaults |
| 1389 | if (!isSmallScreen()) { |
| 1390 | getCards().forEach(c => placeCardInZone(c, ZONES.SIDEBAR, { animate: false })); |
| 1391 | } else { |
| 1392 | getCards().forEach(c => { |
| 1393 | const zone = (c.id === 'uploadCard') ? ZONES.TOP_LEFT : ZONES.TOP_RIGHT; |
| 1394 | placeCardInZone(c, zone, { animate: false }); |
| 1395 | }); |
| 1396 | } |
| 1397 | updateTopZoneLayout(); |
| 1398 | updateSidebarVisibility(); |
| 1399 | saveCurrentLayout(); // initialize baseline so future moves persist |
| 1400 | } |
| 1401 | |
| 1402 | // -------------------- public API -------------------- |
| 1403 | export function loadSidebarOrder() { |
no test coverage detected