Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Pewiz/ulagos360/llms.txt

Use this file to discover all available pages before exploring further.

ULagos 360° protects your space-occupancy data with a two-layer automatic backup system. Every time a space status changes the current state is written to localStorage, and a full snapshot is taken on a 15-second interval. If the browser crashes, the tab is closed, or the device loses power mid-session, a tutor can recover the full spaces grid in a single click without contacting the server.

How Backups Are Written

The usePersistentBackup hook manages all backup writes. It runs as a side-effect that reacts to every change in the Zustand spaces object and also registers lifecycle event listeners so the latest snapshot is always on disk before the page unloads.
// src/hooks/usePersistentBackup.js
const createBackup = () => {
  if (spaces && Object.keys(spaces).length > 0) {
    // Primary backup — plain spaces object
    localStorage.setItem(
      "ulagos360_spaces_backup",
      JSON.stringify(spaces)
    );

    // Emergency backup — includes metadata
    localStorage.setItem(
      "ulagos360_emergency_backup",
      JSON.stringify({
        spaces,
        timestamp: new Date().toISOString(),
        version: "2.0",
      })
    );
  }
};

// Runs immediately, then every 15 seconds
createBackup();
intervalRef.current = setInterval(createBackup, 15000);
Additionally, updateSpace in spacesStore.js writes ulagos360_spaces_backup inline every time any single space is updated, giving per-change granularity between the 15-second ticks.

Backup Schedule

TriggerKey(s) writtenContents
Every space status changeulagos360_spaces_backupFull spaces object
Every 15 seconds (interval)ulagos360_spaces_backup + ulagos360_emergency_backupSpaces + ISO timestamp + version: "2.0"
Page hide / tab switch (visibilitychange)Both keysSame as above
Tab / window close (beforeunload)Both keysSame as above

Manual Recovery

The recovery button appears in the header only when spacesCount === 0 — that is, when the spaces grid is empty and there is likely backup data worth restoring.
1

Notice the empty spaces grid

If you open the app and the grid shows 0 spaces, or all spaces disappear unexpectedly, this is the signal that a recovery may be needed.
2

Find the ↺ recovery button

Look for the RotateCcw (↺) icon button inside the user chip in the header — it is displayed in yellow and only appears when spacesCount === 0 and the onEmergencyRecover handler is available.
3

Click to recover

Click the ↺ button. The recoverFromBackup() function from usePersistentBackup is called:
// src/hooks/usePersistentBackup.js
const recoverFromBackup = () => {
  // 1. Try primary backup first
  const primaryBackup = localStorage.getItem("ulagos360_spaces_backup");
  if (primaryBackup) {
    const spacesData = JSON.parse(primaryBackup);
    if (spacesData && Object.keys(spacesData).length > 0) {
      return spacesData;
    }
  }

  // 2. Fall back to emergency backup
  const emergencyBackup = localStorage.getItem("ulagos360_emergency_backup");
  if (emergencyBackup) {
    const backupData = JSON.parse(emergencyBackup);
    if (backupData.spaces && Object.keys(backupData.spaces).length > 0) {
      return backupData.spaces;
    }
  }

  return null; // Nothing to recover
};
4

Verify the restored state

The spaces grid repopulates with the last backed-up state. Status updates from the server resume normally. If the socket is connected, the next get_all_spaces response will reconcile any differences with the server state.

Recovery Priority

The function always tries the most recent data source first:
  1. Primary backupulagos360_spaces_backup (plain spaces object, updated on every change)
  2. Emergency backupulagos360_emergency_backup (spaces + metadata, updated every 15 s and on page hide/unload)
  3. null — nothing was found; the grid remains empty and the server will provide the state on the next socket sync
The emergency backup includes a timestamp (ISO 8601) and a version: "2.0" field. If you need to debug a data-loss incident, open DevTools → Application → Local Storage and inspect ulagos360_emergency_backup to confirm exactly when the last full snapshot was written.
Backup data is stored exclusively in the browser’s localStorage on the device where the session is running. Clearing browser storage, using Incognito/Private mode, switching to a different browser, or accessing the app from another device will not have access to backups created elsewhere. Always use the same browser and device for a continuous session.

Build docs developers (and LLMs) love