All files / app/services default-list.ts

81.25% Statements 13/16
88.88% Branches 8/9
100% Functions 4/4
76.92% Lines 10/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37          3x 3x     2x       2x 2x                   3x       3x 3x 3x   3x        
import { Injectable } from '@angular/core';
 
@Injectable({
  providedIn: 'root',
})
export class DefaultList {
  protected defaultList: bigint | null = null;
 
  constructor() {
    this.loadDefaultList();
  }
 
  private loadDefaultList(): void {
    const stored = localStorage.getItem('defaultList');
    Iif (stored) {
      try {
        this.defaultList = BigInt(stored);
      } catch (e) {
        console.error('Failed to parse default list ID from localStorage:', e);
      }
    }
  }
 
  getDefaultList(): bigint | null {
    return this.defaultList;
  }
 
  setDefaultList(listId: bigint | null): void {
    this.defaultList = listId;
    if (listId !== null) {
      localStorage.setItem('defaultList', listId.toString());
    } else {
      localStorage.removeItem('defaultList');
    }
  }
}