Files
doneit-web/src/app/store/presidential-actions-store.service.ts
T
Peter Maquiran 9493179efd save all
2023-01-12 15:27:09 +01:00

48 lines
1013 B
TypeScript

import { Injectable } from '@angular/core';
import { localstoreService } from './localstore.service'
import { AES, enc, SHA1 } from 'crypto-js'
import { Publication } from 'src/app/models/publication';
@Injectable({
providedIn: 'root'
})
export class PresidentialActionsStoreService {
// main data
private _list: Publication[] = []
// local storage keyName
private keyName: string;
constructor() {
this.keyName = (SHA1("PresidentialActionsStoreService"+ 'presidentialActions/local')).toString()
setTimeout(()=>{
let restore = localstoreService.get(this.keyName, [])
this._list = restore.list
}, 10)
}
get list() {
return this._list
}
reset(list: Publication[]) {
this._list = list
this.save(this._list)
}
private save(list: Publication[]) {
setTimeout(()=> {
localstoreService.set(this.keyName, {
list: this._list
})
}, 10)
}
}
export const PresidentialActionsStore = new PresidentialActionsStoreService()