mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
48 lines
1013 B
TypeScript
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()
|