diff --git a/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts b/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts index a90cb735..665b3992 100644 --- a/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts +++ b/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts @@ -186,7 +186,7 @@ export class AttendScanService { public updateFirebaseDocument(resultObject: any) { try { - let currentFirebaseDocument = this.common.sharedService.getSharedData('firebase-document'); + let currentFirebaseDocument = this.common.sharedService.getSharedData('firebase-document', false); let currentSwipeArray = currentFirebaseDocument.document.swipeData; if (currentSwipeArray) { currentSwipeArray.push(resultObject); @@ -200,7 +200,12 @@ export class AttendScanService { }; console.log(updatedDocument); this.firebasex.updateDocumentInFirestoreCollection(this.userData.EMPLOYEE_NUMBER, updatedDocument, this.collection, () => { - console.log("Successfully added document with id=" + this.userData.EMPLOYEE_NUMBER); + console.log("Successfully updated document with id = " + this.userData.EMPLOYEE_NUMBER); + const result = { + isDocumentAvailable: true, + document: updatedDocument + }; + this.common.sharedService.setSharedData(result, 'firebase-document'); }, (error) => { console.error("Error adding document: " + error); }); @@ -247,6 +252,11 @@ export class AttendScanService { }; this.firebasex.setDocumentInFirestoreCollection(this.userData.EMPLOYEE_NUMBER, newDocument, this.collection, () => { console.log("Successfully added document"); + const result = { + isDocumentAvailable: true, + document: newDocument + }; + this.common.sharedService.setSharedData(result, 'firebase-document'); }, (error) => { console.error("Error adding document: "+error); });