mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Fix storage service
This commit is contained in:
@@ -184,7 +184,7 @@ export class HomePage implements OnInit {
|
|||||||
|
|
||||||
this.webNotificationPopupService.sendNotification(DataArray.Object)
|
this.webNotificationPopupService.sendNotification(DataArray.Object)
|
||||||
|
|
||||||
this.storageService.get('Notifications').then((data)=>{
|
this.storageService.get('Notifications').then((data:any)=>{
|
||||||
data.push(DataArray)
|
data.push(DataArray)
|
||||||
this.storageService.store("Notifications", data)
|
this.storageService.store("Notifications", data)
|
||||||
}).catch(()=>{
|
}).catch(()=>{
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ export class ListBoxService {
|
|||||||
|
|
||||||
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, {segment = 'todo'}) {
|
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, {segment = 'todo'}) {
|
||||||
|
|
||||||
console.log('eventSource: EventListStore[]',eventSource)
|
|
||||||
|
|
||||||
if(profile != 'all') {
|
if(profile != 'all') {
|
||||||
eventSource = this.filterProfile(eventSource, profile)
|
eventSource = this.filterProfile(eventSource, profile)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ export class WebNotificationPopupService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendNotification(message) {
|
sendNotification(message) {
|
||||||
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {}
|
||||||
|
else {return false}
|
||||||
|
|
||||||
var n = new Notification(message);
|
var n = new Notification(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ export class NotificationsService {
|
|||||||
registerCallback(type: string, funx: Function, object: any = {} ) {
|
registerCallback(type: string, funx: Function, object: any = {} ) {
|
||||||
|
|
||||||
this.callbacks.push({type, funx})
|
this.callbacks.push({type, funx})
|
||||||
if(!object.hasOwnProperty('desktop') && object['desktop'] != false) {
|
synchro.registerCallback('Notification',funx, type)
|
||||||
synchro.registerCallback('Notification',funx, type)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -133,8 +133,8 @@ class SynchroService {
|
|||||||
|
|
||||||
if(idConnection != this.id ) {
|
if(idConnection != this.id ) {
|
||||||
|
|
||||||
if(window['platform'].is('desktop') || this.platform.is('mobileweb')) {}
|
//if(window['platform'].is('desktop') || this.platform.is('mobileweb')) {}
|
||||||
else return false
|
//else return false
|
||||||
|
|
||||||
if(environment.production) return false
|
if(environment.production) return false
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ const { Storage } = Plugins; */
|
|||||||
export class StorageService {
|
export class StorageService {
|
||||||
private keyName: string;
|
private keyName: string;
|
||||||
|
|
||||||
|
|
||||||
constructor(private storage:Storage,
|
constructor(private storage:Storage,
|
||||||
private platform: Platform
|
private platform: Platform
|
||||||
) {}
|
) {}
|
||||||
@@ -22,50 +21,27 @@ const { Storage } = Plugins; */
|
|||||||
|
|
||||||
// Store the value
|
// Store the value
|
||||||
async store(key: string, value: any) {
|
async store(key: string, value: any) {
|
||||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
|
||||||
await localstoreService.set(this.key(key), value)
|
await localstoreService.set(this.key(key), value)
|
||||||
} else {
|
|
||||||
const encryptedValue = btoa(escape(JSON.stringify(value)));
|
|
||||||
await this.storage.set(key, encryptedValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// Get the value
|
// Get the value
|
||||||
async get(key: string) {
|
async get(key: string): Promise<any> {
|
||||||
|
|
||||||
|
|
||||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
|
||||||
return new Promise((resolve, reject)=>{
|
|
||||||
const data = localstoreService.get(this.key(key), false)
|
|
||||||
if(data) resolve(data)
|
|
||||||
else reject(data)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
const ret = await this.storage.get(key).then((val) => { return val; });
|
|
||||||
try {
|
|
||||||
return JSON.parse(unescape(atob(ret)));
|
|
||||||
} catch (error) {
|
|
||||||
if(ret == 'ée') {
|
|
||||||
throw(key+' not found')
|
|
||||||
}
|
|
||||||
return unescape(atob(ret))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return new Promise((resolve, reject)=>{
|
||||||
|
const data = localstoreService.get(this.key(key), false)
|
||||||
|
if(data) resolve(data)
|
||||||
|
else reject(data)
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(key: string){
|
async remove(key: string){
|
||||||
|
|
||||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
await localstoreService.delete(this.key(key))
|
||||||
await localstoreService.delete(this.key(key))
|
|
||||||
} else {
|
|
||||||
await this.storage.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Get the value
|
// Get the value
|
||||||
async get(storageKey: string) {
|
async get(storageKey: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user