import {LocalStorageService, WebbpmStorage} from "@webbpm/base-package";
import {AuthorizationService} from "./authorization.service";
import {Injectable} from "@angular/core";

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

  constructor(protected authService: AuthorizationService) {
    super();
  }

  readWebbpmStorage(storageId: string): WebbpmStorage {
    const userId: string = this.authService.getUserId();
    const userStorageId = `user_${userId}_${storageId}`;
    return super.readWebbpmStorage(userStorageId);
  }

  readTemporalWebbpmStorage(storageId: string): WebbpmStorage {
    const userId: string = this.authService.getUserId();
    const userStorageId = `user_${userId}_${storageId}`;
    return super.readTemporalWebbpmStorage(userStorageId);
  }
}