mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
Add publication to local storage
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user