Commit 3265db80 authored by Merzough Münker's avatar Merzough Münker
Browse files

fix: remove the old LocalStorageService

parent fcc25c2c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ export * from './lib/footer.service';
export * from './lib/header.service';
export * from './lib/image-loader.service';
export * from './lib/loading-indicator.service';
export * from './lib/local-storage.service';
export * from './lib/reset.service';
export * from './lib/version.service';
export * from './lib/window-container-sidenav.service';
+0 −26
Original line number Diff line number Diff line
import { Injectable } from '@angular/core';

@Injectable({ providedIn: 'root' })
export class LocalStorageService {

  public has(key: string): boolean {
    return localStorage.getItem(key) !== null;
  }

  public set(key: string, value: any): void {
    if (typeof value !== 'string') {
      localStorage.setItem(key, JSON.stringify(value));
    } else {
      localStorage.setItem(key, value);
    }
  }

  public get(key: string): string | null {
    return localStorage.getItem(key);
  }

  public remove(key: string): void {
    localStorage.removeItem(key);
  }

}
+0 −5
Original line number Diff line number Diff line
{
  "lib": {
    "entryFile": "src/index.ts"
  }
}
+0 −3
Original line number Diff line number Diff line
// region 
export * from './lib/local-storage.service.helper-spec';
// endregion
+0 −40
Original line number Diff line number Diff line
import {
  Injectable,
  Provider,
} from '@angular/core';
import { LocalStorageService } from '@rxap/services';

@Injectable()
export class LocalStorageServiceFake implements LocalStorageService {

  public readonly localStorage = new Map<string, string>();

  public get(key: string): string | null {
    return this.localStorage.get(key) ?? null;
  }

  public has(key: string): boolean {
    return this.localStorage.has(key);
  }

  public remove(key: string): void {
    this.localStorage.delete(key);
  }

  public set(key: string, value: any): void {
    if (typeof value !== 'string') {
      this.localStorage.set(key, JSON.stringify(value));
    } else {
      this.localStorage.set(key, value);
    }
  }

}

export const LOCAL_STORAGE_SERVICE_FAKE_PROVIDER: Provider[] = [
  LocalStorageServiceFake,
  {
    provide: LocalStorageService,
    useExisting: LocalStorageServiceFake,
  },
];
Loading