mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[feat-75] support import for maps exported by BSM
This commit is contained in:
@@ -121,23 +121,7 @@ export function MapsPlaylistsPanel({ version, isActive }: Props) {
|
||||
return;
|
||||
}
|
||||
|
||||
const importCount = await mapsManager.importMaps(paths, version);
|
||||
if (importCount === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (importCount < paths.length) {
|
||||
notifications.notifySuccess({
|
||||
title: "notifications.maps.import-map.titles.success",
|
||||
desc: "notifications.maps.import-map.msgs.some-success",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
notifications.notifySuccess({
|
||||
title: "notifications.maps.import-map.titles.success",
|
||||
desc: "notifications.maps.import-map.msgs.success",
|
||||
});
|
||||
await mapsManager.importMaps(paths, version);
|
||||
}
|
||||
|
||||
const dropDownItems = ((): DropDownItem[] => {
|
||||
|
||||
+10
-6
@@ -123,20 +123,24 @@ export const LocalMapsListPanel = forwardRef<LocalMapsListPanelRef, Props>(({ ve
|
||||
|
||||
}, [isActiveOnce, version])
|
||||
|
||||
const importListener = (importMap: BsmLocalMap, targetVersion?: BSVersion) => {
|
||||
const importListener = (importMaps: BsmLocalMap[], targetVersion?: BSVersion) => {
|
||||
if (!equal(targetVersion, version)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const mapsCopy = maps ? [ ...maps ] : [];
|
||||
|
||||
// importMap can collide with existing map
|
||||
const index = maps.findIndex(map => map.songDetails?.name === importMap.songDetails.name);
|
||||
if (index > -1) {
|
||||
mapsCopy.splice(index, 1);
|
||||
for (const importMap of importMaps) {
|
||||
if (importMap.songDetails) {
|
||||
// importMap can collide with existing map
|
||||
const index = maps.findIndex(map => map.songDetails?.name === importMap.songDetails.name);
|
||||
if (index > -1) {
|
||||
mapsCopy.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setMaps([importMap, ...mapsCopy]);
|
||||
setMaps([...importMaps, ...mapsCopy]);
|
||||
};
|
||||
|
||||
const loadMaps = () => {
|
||||
|
||||
Reference in New Issue
Block a user