Fixed 2 bugs with map loading and sending

When a map was sent the receiver didn't save the resolutions tihs meant that if the original map owner left or wasn't the party leader the map would be blank when new users joined. Also if a map sender left when sending a map and rejoined their version of the map would be overriden by a corrupted version.
This commit is contained in:
Mitchell McCaffrey
2020-08-28 17:06:13 +10:00
parent 7f7471b1e9
commit b4e52ebb23
3 changed files with 51 additions and 29 deletions

View File

@@ -147,6 +147,10 @@ export function MapDataProvider({ children }) {
return maps.find((map) => map.id === mapId);
}
async function getMapFromDB(mapId) {
return await database.table("maps").get(mapId);
}
const ownedMaps = maps.filter((map) => map.owner === userId);
const value = {
@@ -160,6 +164,7 @@ export function MapDataProvider({ children }) {
updateMapState,
putMap,
getMap,
getMapFromDB,
};
return (
<MapDataContext.Provider value={value}>{children}</MapDataContext.Provider>