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