MCPcopy Create free account
hub / github.com/error311/FileRise / applyUserLayoutOrDefault

Function applyUserLayoutOrDefault

public/js/dragAndDrop.js:1361–1400  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1359
1360// -------------------- defaults + layout --------------------
1361function 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 --------------------
1403export function loadSidebarOrder() {

Callers 3

setZonesCollapsedFunction · 0.85
loadSidebarOrderFunction · 0.85
runFunction · 0.85

Calls 8

readLayoutFunction · 0.85
isSmallScreenFunction · 0.85
applyZoneOrderFunction · 0.85
getCardsFunction · 0.85
placeCardInZoneFunction · 0.85
updateTopZoneLayoutFunction · 0.85
updateSidebarVisibilityFunction · 0.85
saveCurrentLayoutFunction · 0.85

Tested by

no test coverage detected