Skip to content

Commit

Permalink
Wfnews 1631 (#1572)
Browse files Browse the repository at this point in the history
* use 20px if safe-area-inset not detectable

* typo on notification title

* commented out in-app notification section

* remove bracket from notifiation message body

* try out

* safe-area in map screen got ignored

* change notification message again. set 10 sec apperance time for notification snackbar

* more styling tweak

* remove test

* emit location notification if click in app notification

* avoiding duplicate offline report

* remove debugger

* improve by adding try catch to await
  • Loading branch information
yzlucas authored Feb 2, 2024
1 parent f312b13 commit 55ef4b3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class RoFContactPage extends RoFPage {
}

checkOnlineStatus() {
this.commonUtilityService.pingSerivce().subscribe(
this.commonUtilityService.pingService().subscribe(
() => {
this.offLine = false;
this.cdr.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ this.reportOfFire.headingDetectionActive = true;
}

checkOnlineStatus() {
this.commonUtilityService.pingSerivce().subscribe(
this.commonUtilityService.pingService().subscribe(
() => {
this.offLine = false;
this.cdr.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ this.nextId = 'disclaimer-page';
}

checkOnlineStatus() {
this.commonUtilityService.pingSerivce().subscribe(
this.commonUtilityService.pingService().subscribe(
() => {
this.offLine = false;
this.cdr.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ valueMatch = trimmedAddress.substring(0, valueLength);
return Promise.race([timeoutPromise, locationPromise]);
}

pingSerivce(): Observable<any> {
pingService(): Observable<any> {
const url = this.appConfigService.getConfig().rest['wfnews'];
return this.http.get(url);
}
Expand Down Expand Up @@ -208,7 +208,7 @@ valueMatch = trimmedAddress.substring(0, valueLength);

async checkOnlineStatus(): Promise<boolean> {
try {
await this.pingSerivce().toPromise();
await this.pingService().toPromise();
return true;
} catch (error) {
return false;
Expand Down Expand Up @@ -278,7 +278,7 @@ valueMatch = trimmedAddress.substring(0, valueLength);

async checkOnline() {
try {
await this.pingSerivce().toPromise();
await this.pingService().toPromise();
return true;
} catch (error) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ formData.append('image3', await this.convertToBase64(image3));
return;
}

let storedOfflineReportData;
try {
storedOfflineReportData = await this.storage.get('offlineReportData');
} catch (error) {
console.error('An error occurred while retrieving offlineReportData:', error);
}
if (storedOfflineReportData) {
// in case the device back online right after user store the report into ionic,
// should always check to avoid submit the duplicate one
const offlineReport = JSON.parse(storedOfflineReportData);
if (offlineReport.resource) {
const offlineResource = JSON.parse(offlineReport.resource);
if (offlineResource === resource) {
try {
await this.storage.remove('offlineReportData');
} catch (error) {
console.error('An error occurred while removing offlineReportData:', error);
}
}
}
}
const response = await fetch(rofUrl, {
method: 'POST',
body: formData,
Expand Down Expand Up @@ -212,7 +233,6 @@ formData.append('image3', image3);

if (response.ok) {
// Remove the locally stored data if sync is successful
await this.storage.create();
await this.storage.remove('offlineReportData');
App.removeAllListeners();
// The server successfully processed the report
Expand Down

0 comments on commit 55ef4b3

Please sign in to comment.