mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
49 lines
1005 B
TypeScript
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()
|