Skip to content

Overview

Offline Manager

The Offline Manager is responsible for handling the application's offline capabilities. It provides the following functionalities:

  1. Service Worker Registration: Manages the registration of the service worker to enable offline functionality.
  2. Offline Mode Toggle: Allows users to enable or disable offline mode as needed.
  3. Data Prefetching: Supports on-demand prefetching of classroom or student data to ensure availability during offline usage.
import { writable, get } from 'svelte/store';
import { pwaInfo } from 'virtual:pwa-info';
import DataPrefetcherWebWorker from './data-prefetcher-web-worker?worker';
import type {
    WorkerStartCommandRequest,
    WorkeStudentStartCommandRequest
} from './data-prefetcher-web-worker';
import { offlineDb } from './db';

Implementation can be found in src/lib/offline/OfflineManager.ts.

Offline Db

The Offline Database provides a way to store user operations along with the necessary data when in offline mode. It uses dexie to manage IndexedDB storage and retrieval. It provides the following functionalities:

  1. Ability to store preferences, including various settings like whether the service worker is enabled, what student/classroom data is downloaded, their timestamps, etc.
  2. Ability to store and manage daily attendance.
  3. Ability to store and manage daily assessment records.

Implementation can be found in src/lib/offline/db.ts.