|
1 | 1 | import { HttpClient, HttpErrorResponse } from "@angular/common/http";
|
2 | 2 | import { Injectable } from "@angular/core";
|
3 | 3 | import { DeviceInfo, Device } from "@capacitor/device";
|
4 |
| -import { IAppConfig, getProtectedFieldName } from "data-models"; |
| 4 | +import { IAppConfig, getProtectedFieldName, EXCLUDED_FIELDS } from "data-models"; |
5 | 5 | import { interval } from "rxjs";
|
6 | 6 | import { throwError } from "rxjs";
|
7 | 7 | import { environment } from "src/environments/environment";
|
@@ -70,7 +70,9 @@ export class ServerService extends SyncServiceBase {
|
70 | 70 | this.app_user_id = uuid;
|
71 | 71 | }
|
72 | 72 | console.log("[SERVER] sync data");
|
73 |
| - const contact_fields = this.localStorageService.getAll(); |
| 73 | + const all_contact_fields = this.localStorageService.getAll(); |
| 74 | + const contact_fields = this.removeExcludedContactFields(all_contact_fields); |
| 75 | + |
74 | 76 | const dynamic_data = await this.dynamicDataService.getState();
|
75 | 77 |
|
76 | 78 | // apply temp timestamp to contact fields to sync as latest
|
@@ -115,6 +117,15 @@ export class ServerService extends SyncServiceBase {
|
115 | 117 | });
|
116 | 118 | }
|
117 | 119 |
|
| 120 | + /** Remove any protected fields that should not be synced */ |
| 121 | + private removeExcludedContactFields(contactFields: {}) { |
| 122 | + const { prefix } = this.localStorageService; |
| 123 | + EXCLUDED_FIELDS.forEach( |
| 124 | + (field) => delete contactFields[`${prefix}.${getProtectedFieldName(field)}`] |
| 125 | + ); |
| 126 | + return contactFields; |
| 127 | + } |
| 128 | + |
118 | 129 | private handleError(error: HttpErrorResponse) {
|
119 | 130 | // sync failed, retry later (?)
|
120 | 131 | return throwError("Could not connect to server");
|
|
0 commit comments