diff --git a/.env.production b/.env.production index f8a939f..4577712 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,5 @@ -REACT_APP_BROKER_URL=https://test.owlbear.rodeo -REACT_APP_ICE_SERVERS_URL=https://test.owlbear.rodeo/iceservers +REACT_APP_BROKER_URL=https://connect.owlbear.rodeo +REACT_APP_ICE_SERVERS_URL=https://connect.owlbear.rodeo/iceservers REACT_APP_STRIPE_API_KEY=pk_live_MJjzi5djj524Y7h3fL5PNh4e00a852XD51 REACT_APP_STRIPE_URL=https://payment.owlbear.rodeo REACT_APP_VERSION=$npm_package_version diff --git a/public/index.html b/public/index.html index f9e20ed..16cc9c9 100644 --- a/public/index.html +++ b/public/index.html @@ -28,8 +28,8 @@ - - + +
diff --git a/src/components/map/MapFog.js b/src/components/map/MapFog.js index ab205dc..d9e78a8 100644 --- a/src/components/map/MapFog.js +++ b/src/components/map/MapFog.js @@ -336,7 +336,7 @@ function MapFog({ } else if (toolSettings.type === "toggle") { onShapesEdit( editingShapes.map((shape) => ({ - ...shape, + id: shape.id, visible: !shape.visible, })) ); diff --git a/src/contexts/TokenDataContext.js b/src/contexts/TokenDataContext.js index b9b45fd..0697375 100644 --- a/src/contexts/TokenDataContext.js +++ b/src/contexts/TokenDataContext.js @@ -185,6 +185,11 @@ export function TokenDataProvider({ children }) { [database, updateCache, userId] ); + async function getTokenFromDB(tokenId) { + let token = await database.table("tokens").get(tokenId); + return token; + } + const ownedTokens = tokens.filter((token) => token.owner === userId); const tokensById = tokens.reduce((obj, token) => { diff --git a/src/database.js b/src/database.js index 6164f28..53e92b3 100644 --- a/src/database.js +++ b/src/database.js @@ -280,6 +280,30 @@ function loadVersions(db) { state.editFlags = [...state.editFlags, "notes"]; }); }); + + // 1.7.0 (hotfix) - Optimized fog shape edits to only include needed data + db.version(17) + .stores({}) + .upgrade((tx) => { + return tx + .table("states") + .toCollection() + .modify((state) => { + for (let i = 0; i < state.fogDrawActions.length; i++) { + const action = state.fogDrawActions[i]; + if (action && action.type === "edit") { + for (let j = 0; j < action.shapes.length; j++) { + const shape = action.shapes[j]; + const temp = { ...shape }; + state.fogDrawActions[i].shapes[j] = { + id: temp.id, + visible: temp.visible, + }; + } + } + } + }); + }); } // Get the dexie database used in DatabaseContext diff --git a/src/helpers/drawing.js b/src/helpers/drawing.js index 1c7ff53..5f9a082 100644 --- a/src/helpers/drawing.js +++ b/src/helpers/drawing.js @@ -225,11 +225,16 @@ export function drawActionsToShapes(actions, actionIndex) { if (!action) { continue; } - if (action.type === "add" || action.type === "edit") { + if (action.type === "add") { for (let shape of action.shapes) { shapesById[shape.id] = shape; } } + if (action.type === "edit") { + for (let edit of action.shapes) { + shapesById[edit.id] = { ...shapesById[edit.id], ...edit }; + } + } if (action.type === "remove") { shapesById = omit(shapesById, action.shapeIds); } diff --git a/src/network/NetworkedMapAndTokens.js b/src/network/NetworkedMapAndTokens.js index d73d02e..4211e20 100644 --- a/src/network/NetworkedMapAndTokens.js +++ b/src/network/NetworkedMapAndTokens.js @@ -35,7 +35,9 @@ function NetworkedMapAndTokens({ session }) { isLoading, } = useContext(MapLoadingContext); - const { putToken, getToken, updateToken } = useContext(TokenDataContext); + const { putToken, getToken, updateToken, getTokenFromDB } = useContext( + TokenDataContext + ); const { putMap, updateMap, @@ -329,7 +331,6 @@ function NetworkedMapAndTokens({ session }) { async function handlePeerData({ id, data, reply }) { if (id === "mapRequest") { const map = await getMapFromDB(data); - function replyWithMap(preview, resolution) { let response = { ...map, @@ -393,19 +394,23 @@ function NetworkedMapAndTokens({ session }) { if (id === "mapResponse") { const newMap = data; - setCurrentMap(newMap); - await putMap(newMap); + if (newMap?.id) { + setCurrentMap(newMap); + await putMap(newMap); + } assetLoadFinish(); } if (id === "tokenRequest") { - const token = getToken(data); + const token = await getTokenFromDB(data); // Add a last used property for cache invalidation reply("tokenResponse", { ...token, lastUsed: Date.now() }, "token"); } if (id === "tokenResponse") { const newToken = data; - await putToken(newToken); + if (newToken?.id) { + await putToken(newToken); + } assetLoadFinish(); } }