Merge pull request #262 from Zagrios/hotflix/cant-delete-maps-in-shared-contents

[hotfix] fix cant delete maps in shared contents + fix conflict with …
This commit is contained in:
MathieuG-P
2023-06-28 20:43:48 +02:00
committed by GitHub
2 changed files with 9 additions and 2 deletions
@@ -137,10 +137,17 @@ export const LocalMapsListPanel = forwardRef(({version, className, filter, searc
const removeMapsFromList = (mapsToRemove: BsmLocalMap[]) => {
const filtredMaps = maps.filter(map => !mapsToRemove.some(toDeleteMaps => map.hash === toDeleteMaps.hash));
setMaps(() => filtredMaps);
const filtredSelectedMaps = selectedMaps$.value.filter(map => !mapsToRemove.some(toDeleteMaps => map.hash === toDeleteMaps.hash));
selectedMaps$.next(filtredSelectedMaps);
};
const handleDelete = useCallback((map: BsmLocalMap) => {
mapsManager.deleteMaps([map], version).then(res => res && removeMapsFromList([map]));
mapsManager.deleteMaps([map], version).then(res => {
if(!res){ return; }
removeMapsFromList([map]);
});
}, [version, maps]);
const onMapSelected = useCallback((map: BsmLocalMap) => {
@@ -86,7 +86,7 @@ export class MapsManagerService {
public async deleteMaps(maps: BsmLocalMap[], version?: BSVersion): Promise<boolean>{
const versionLinked = await this.versionHaveMapsLinked(version);
const versionLinked = !version || await this.versionHaveMapsLinked(version);
const askModal = maps.length > 1 || !this.config.get<boolean>(MapsManagerService.REMEMBER_CHOICE_DELETE_MAP_KEY);