Updated update map
This commit is contained in:
parent
b70bcdabd2
commit
f8d7f7f19f
@ -145,7 +145,9 @@ export function MapDataProvider({ children }) {
|
||||
}
|
||||
return newMaps;
|
||||
});
|
||||
console.log("updated");
|
||||
|
||||
const updatedMap = (await database.table("maps").get(id)) || {};
|
||||
return { ...updatedMap, ...update };
|
||||
}
|
||||
|
||||
async function updateMaps(ids, update) {
|
||||
|
@ -280,8 +280,8 @@ function SelectMapModal({
|
||||
if (selectedMapIds.length === 1) {
|
||||
// Update last used for cache invalidation
|
||||
const lastUsed = Date.now();
|
||||
await updateMap(selectedMapIds[0], { lastUsed });
|
||||
onMapChange({ ...selectedMaps[0], lastUsed }, selectedMapStates[0]);
|
||||
const updatedMap = await updateMap(selectedMapIds[0], { lastUsed });
|
||||
onMapChange(updatedMap, selectedMapStates[0]);
|
||||
} else {
|
||||
onMapChange(null, null);
|
||||
}
|
||||
|
@ -247,8 +247,8 @@ function NetworkedMapAndTokens({ session }) {
|
||||
if (cachedMap && cachedMap.lastModified >= newMap.lastModified) {
|
||||
// Update last used for cache invalidation
|
||||
const lastUsed = Date.now();
|
||||
await updateMap(cachedMap.id, { lastUsed });
|
||||
setCurrentMap({ ...cachedMap, lastUsed });
|
||||
const updatedMap = await updateMap(cachedMap.id, { lastUsed });
|
||||
setCurrentMap(updatedMap);
|
||||
} else {
|
||||
// Save map data but remove last modified so if there is an error
|
||||
// during the map request the cache is invalid. Also add last used
|
||||
@ -319,9 +319,8 @@ function NetworkedMapAndTokens({ session }) {
|
||||
}
|
||||
if (id === "mapResponse") {
|
||||
const { id, ...update } = data;
|
||||
await updateMap(id, update);
|
||||
const newMap = await getMapFromDB(data.id);
|
||||
setCurrentMap(newMap);
|
||||
const updatedMap = await updateMap(id, update);
|
||||
setCurrentMap(updatedMap);
|
||||
}
|
||||
if (id === "mapState") {
|
||||
setCurrentMapState(data);
|
||||
|
Loading…
Reference in New Issue
Block a user