Remove map states of corrupted maps on import
This commit is contained in:
parent
1ea05e8686
commit
8f78da4e11
@ -325,27 +325,42 @@ function ImportExportModal({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// compare items added to newAssetIds against those that were processed
|
||||||
const unprocessedAssets = Object.keys(newAssetIds).filter(item => processedAssetIds.indexOf(item) < 0);
|
const unprocessedAssets = Object.keys(newAssetIds).filter(item => processedAssetIds.indexOf(item) < 0);
|
||||||
let unprocessedMaps = 0
|
let unprocessedMaps = 0
|
||||||
let unprocessedTokens = 0
|
let unprocessedTokens = 0
|
||||||
|
// check if there are any items that have been unprocessed
|
||||||
if (unprocessedAssets.length > 0) {
|
if (unprocessedAssets.length > 0) {
|
||||||
const unprocessedItems: { id: string, name: string }[] = []
|
const unprocessedItems: { id: string, name: string }[] = []
|
||||||
for (let item of unprocessedAssets) {
|
for (let item of unprocessedAssets) {
|
||||||
|
// get information of unprocessed item from oldAssetIds list
|
||||||
let unprocessedItem = oldAssetIds[item]
|
let unprocessedItem = oldAssetIds[item]
|
||||||
|
|
||||||
|
// should only remove corrupted asset once (one map can have multiple unprocessed assets)
|
||||||
if (!!!(unprocessedItems.some(value => value.id === unprocessedItem.itemId))) {
|
if (!!!(unprocessedItems.some(value => value.id === unprocessedItem.itemId))) {
|
||||||
unprocessedItems.push({ id: unprocessedItem.itemId, name: unprocessedItem.itemName })
|
unprocessedItems.push({ id: unprocessedItem.itemId, name: unprocessedItem.itemName })
|
||||||
if (unprocessedItem.item === "map") {
|
if (unprocessedItem.item === "map") {
|
||||||
unprocessedMaps += 1
|
unprocessedMaps += 1
|
||||||
|
|
||||||
|
// remove corrupt map from newMaps list -> otherwise corrupt data will be imported
|
||||||
const index = newMaps.findIndex(map => map.id === unprocessedItem.newId)
|
const index = newMaps.findIndex(map => map.id === unprocessedItem.newId)
|
||||||
|
if (index !== -1) {
|
||||||
newMaps.splice(index, 1)
|
newMaps.splice(index, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const stateIndex = newStates.findIndex(state => state.mapId === unprocessedItem.newId)
|
||||||
|
if (stateIndex !== -1) {
|
||||||
|
newStates.splice(stateIndex, 1)
|
||||||
|
}
|
||||||
} else if (unprocessedItem.item === "token") {
|
} else if (unprocessedItem.item === "token") {
|
||||||
unprocessedTokens += 1
|
unprocessedTokens += 1
|
||||||
const index = newTokens.findIndex(token => token.id === unprocessedItem.newId)
|
const index = newTokens.findIndex(token => token.id === unprocessedItem.newId)
|
||||||
|
if (index !== -1) {
|
||||||
newTokens.splice(index, 1)
|
newTokens.splice(index, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const unprocessedItemNames = unprocessedItems.map(item => item.name)
|
const unprocessedItemNames = unprocessedItems.map(item => item.name)
|
||||||
addWarningToast("Could not import item(s)", unprocessedItemNames)
|
addWarningToast("Could not import item(s)", unprocessedItemNames)
|
||||||
|
Loading…
Reference in New Issue
Block a user