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);
|
return this.serviceRefData.get<Array<DropZoneResp>>(RefData.Dropzone, callToApi);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SetFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
public SetFavoriteDropZone(selectedDz: DropZoneResp) {
|
||||||
selectedDz.isFavorite = true;
|
selectedDz.isFavorite = true;
|
||||||
|
|
||||||
this.http.put(`${this.apiUrl}/DropZone/AddToFavorite/${selectedDz.id}`,
|
this.http.put(`${this.apiUrl}/DropZone/AddToFavorite/${selectedDz.id}`,
|
||||||
selectedDz,
|
selectedDz,
|
||||||
{ headers: this.headers })
|
{ headers: this.headers })
|
||||||
.subscribe();
|
.subscribe(() => {
|
||||||
|
this.serviceRefData.delete(RefData.Dropzone);
|
||||||
return true;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoveFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
public RemoveFavoriteDropZone(selectedDz: DropZoneResp) {
|
||||||
selectedDz.isFavorite = false;
|
selectedDz.isFavorite = false;
|
||||||
|
|
||||||
this.http.put(`${this.apiUrl}/DropZone/RemoveToFavorite${selectedDz.id}`,
|
this.http.put(`${this.apiUrl}/DropZone/RemoveToFavorite${selectedDz.id}`,
|
||||||
selectedDz,
|
selectedDz,
|
||||||
{ headers: this.headers })
|
{ headers: this.headers })
|
||||||
.subscribe();
|
.subscribe(() => {
|
||||||
|
this.serviceRefData.delete(RefData.Dropzone);
|
||||||
return true;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddDropZone(latitude: string,
|
public AddDropZone(latitude: string,
|
||||||
@@ -72,6 +72,7 @@ export class DropzoneService extends BaseService {
|
|||||||
isFavorite: isFavorite
|
isFavorite: isFavorite
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.serviceRefData.delete(RefData.Dropzone);
|
||||||
return this.http.post(`${this.apiUrl}/DropZone`,
|
return this.http.post(`${this.apiUrl}/DropZone`,
|
||||||
bodyNewDropZone,
|
bodyNewDropZone,
|
||||||
{ headers: this.headers });
|
{ headers: this.headers });
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export class GearService extends BaseService {
|
|||||||
reserveCanopy: reserveCanopy
|
reserveCanopy: reserveCanopy
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.serviceRefData.delete(RefData.Gear);
|
||||||
return this.http.post(`${this.apiUrl}/Gear`, bodyNewGear, { headers: this.headers});
|
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>>();
|
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);
|
const cached = this.cache.get(key);
|
||||||
|
|
||||||
if (cached) {
|
if (cached) {
|
||||||
@@ -27,4 +31,8 @@ export class ServiceRefData {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public delete(key: RefData) {
|
||||||
|
this.cache.delete(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user