Ajout d'un reset de cache après un ajout
This commit is contained in:
@@ -30,26 +30,26 @@ export class DropzoneService extends BaseService {
|
||||
return this.serviceRefData.get<Array<DropZoneResp>>(RefData.Dropzone, callToApi);
|
||||
}
|
||||
|
||||
public SetFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
||||
public SetFavoriteDropZone(selectedDz: DropZoneResp) {
|
||||
selectedDz.isFavorite = true;
|
||||
|
||||
this.http.put(`${this.apiUrl}/DropZone/AddToFavorite/${selectedDz.id}`,
|
||||
selectedDz,
|
||||
{ headers: this.headers })
|
||||
.subscribe();
|
||||
|
||||
return true;
|
||||
.subscribe(() => {
|
||||
this.serviceRefData.delete(RefData.Dropzone);
|
||||
});
|
||||
}
|
||||
|
||||
public RemoveFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
||||
public RemoveFavoriteDropZone(selectedDz: DropZoneResp) {
|
||||
selectedDz.isFavorite = false;
|
||||
|
||||
this.http.put(`${this.apiUrl}/DropZone/RemoveToFavorite${selectedDz.id}`,
|
||||
selectedDz,
|
||||
{ headers: this.headers })
|
||||
.subscribe();
|
||||
|
||||
return true;
|
||||
.subscribe(() => {
|
||||
this.serviceRefData.delete(RefData.Dropzone);
|
||||
});
|
||||
}
|
||||
|
||||
public AddDropZone(latitude: string,
|
||||
@@ -72,6 +72,7 @@ export class DropzoneService extends BaseService {
|
||||
isFavorite: isFavorite
|
||||
};
|
||||
|
||||
this.serviceRefData.delete(RefData.Dropzone);
|
||||
return this.http.post(`${this.apiUrl}/DropZone`,
|
||||
bodyNewDropZone,
|
||||
{ headers: this.headers });
|
||||
|
||||
@@ -37,6 +37,7 @@ export class GearService extends BaseService {
|
||||
reserveCanopy: reserveCanopy
|
||||
};
|
||||
|
||||
this.serviceRefData.delete(RefData.Gear);
|
||||
return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, { headers: this.headers});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,11 @@ export class ServiceRefData {
|
||||
this.cache = new Map<RefData, Observable<any>>();
|
||||
}
|
||||
|
||||
public get<T>(key: RefData, callToApi: Observable<T>) : Observable<T> {
|
||||
public get<T>(key: RefData, callToApi: Observable<T>, withResetCache: boolean = false) : Observable<T> {
|
||||
if (withResetCache === true) {
|
||||
this.cache.delete(key);
|
||||
}
|
||||
|
||||
const cached = this.cache.get(key);
|
||||
|
||||
if (cached) {
|
||||
@@ -27,4 +31,8 @@ export class ServiceRefData {
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
public delete(key: RefData) {
|
||||
this.cache.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user