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.storageService.get('Notifications').then((data)=>{
|
||||
this.storageService.get('Notifications').then((data:any)=>{
|
||||
data.push(DataArray)
|
||||
this.storageService.store("Notifications", data)
|
||||
}).catch(()=>{
|
||||
|
||||
@@ -30,8 +30,6 @@ export class ListBoxService {
|
||||
|
||||
list(eventSource: EventListStore[], profile: 'md' | 'pr' | 'all', rangeStartDate, randEndDate, {segment = 'todo'}) {
|
||||
|
||||
console.log('eventSource: EventListStore[]',eventSource)
|
||||
|
||||
if(profile != 'all') {
|
||||
eventSource = this.filterProfile(eventSource, profile)
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@ export class WebNotificationPopupService {
|
||||
}
|
||||
|
||||
sendNotification(message) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {}
|
||||
else {return false}
|
||||
|
||||
var n = new Notification(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,9 +54,7 @@ export class NotificationsService {
|
||||
registerCallback(type: string, funx: Function, object: any = {} ) {
|
||||
|
||||
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(window['platform'].is('desktop') || this.platform.is('mobileweb')) {}
|
||||
else return false
|
||||
//if(window['platform'].is('desktop') || this.platform.is('mobileweb')) {}
|
||||
//else return false
|
||||
|
||||
if(environment.production) return false
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ const { Storage } = Plugins; */
|
||||
export class StorageService {
|
||||
private keyName: string;
|
||||
|
||||
|
||||
constructor(private storage:Storage,
|
||||
private platform: Platform
|
||||
) {}
|
||||
@@ -22,50 +21,27 @@ const { Storage } = Plugins; */
|
||||
|
||||
// Store the value
|
||||
async store(key: string, value: any) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
await localstoreService.set(this.key(key), value)
|
||||
} else {
|
||||
const encryptedValue = btoa(escape(JSON.stringify(value)));
|
||||
await this.storage.set(key, encryptedValue);
|
||||
}
|
||||
|
||||
await localstoreService.set(this.key(key), value)
|
||||
|
||||
}
|
||||
// Get the value
|
||||
async get(key: string) {
|
||||
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
async get(key: string): Promise<any> {
|
||||
|
||||
return new Promise((resolve, reject)=>{
|
||||
const data = localstoreService.get(this.key(key), false)
|
||||
if(data) resolve(data)
|
||||
else reject(data)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
async remove(key: string){
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
await localstoreService.delete(this.key(key))
|
||||
} else {
|
||||
await this.storage.remove(key);
|
||||
}
|
||||
await localstoreService.delete(this.key(key))
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// Get the value
|
||||
async get(storageKey: string) {
|
||||
|
||||
Reference in New Issue
Block a user