Files
doneit-web/src/app/store/publication-list.service.ts
T
Peter Maquiran 8da233c1bc Fix action
2021-08-09 13:56:17 +01:00

49 lines
1005 B
TypeScript

import { Injectable } from '@angular/core'
import { Publication } from 'src/app/models/publication'
import { localstoreService } from './localstore.service'
import { SHA1 } from 'crypto-js'
@Injectable({
providedIn: 'root'
})
export class PublicationListService {
// main data
private _document = {}
// local storage keyName
private keyName: string;
constructor() {
this.keyName = (SHA1(this.constructor.name+ 'view-publication-list/local')).toString()
setTimeout(()=>{
let restore = localstoreService.get(this.keyName, {})
this._document = restore.document || {}
}, 10)
}
get documents() {
return this._document
}
getDocument(folderId) {
return this._document[folderId]
}
add(folderId, document) {
this._document[folderId] = document
setTimeout(()=> {
localstoreService.set(this.keyName, {
document: this._document
})
}, 100)
}
}
export const PublicationListStorage = new PublicationListService()