Add publication to local storage

This commit is contained in:
Peter Maquiran
2021-07-21 20:26:41 +01:00
parent 6460e1ce1a
commit f604c72575
7 changed files with 65 additions and 41 deletions
+16 -12
View File
@@ -9,34 +9,38 @@ import { SHA1 } from 'crypto-js'
export class PublicationListService {
// main data
private _list: Publication[] = []
private _document: Publication[] = []
// local storage keyName
private keyName: string;
constructor() {
this.keyName = (SHA1(this.constructor.name+ ' PublicationTravelFolder/local')).toString()
this.keyName = (SHA1(this.constructor.name+ 'view-publication-list/local')).toString()
setTimeout(()=>{
let restore = localstoreService.get(this.keyName, [])
this._list = restore
this._document = restore
}, 10)
}
get list() {
return this._list
get documents() {
return this._document
}
reset(list: Publication[]) {
this._list = list
this.save(this._list)
getDocument(folderId: string) {
return this._document[folderId]
}
private save(list: Publication[]) {
add(folderId, document) {
this._document[folderId] = document
setTimeout(()=> {
localstoreService.set(this.keyName, list)
}, 10)
localstoreService.set(this.keyName, this._document)
}, 100)
}
}
export const PublicationListStorage = new PublicationListService()