From f2df069a8e8877dc0c2c2fa218cba1c3dd912d9b Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Wed, 20 Jan 2021 20:13:10 +1100 Subject: [PATCH 01/15] Moved back to preview --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 76ae3a2..b25dfa0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "owlbear-rodeo", - "version": "1.7.0", + "version": "1.7.0 (preview)", "private": true, "dependencies": { "@babylonjs/core": "^4.2.0", From 98f7f36bed2916b0da5f48961520790eb5237a66 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Wed, 20 Jan 2021 20:13:10 +1100 Subject: [PATCH 02/15] Moved back to preview --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 76ae3a2..b25dfa0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "owlbear-rodeo", - "version": "1.7.0", + "version": "1.7.0 (preview)", "private": true, "dependencies": { "@babylonjs/core": "^4.2.0", From d2d4d2ae8b24fac5d764f9734c2445f4dff713e5 Mon Sep 17 00:00:00 2001 From: Nicola Thouliss Date: Thu, 21 Jan 2021 15:38:43 +1100 Subject: [PATCH 03/15] Edited app broker url --- .env.production | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From e6ead58934a20f863b29572140985b8e3a8d10b6 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 21 Jan 2021 20:00:02 +1100 Subject: [PATCH 04/15] Update .env.production --- .env.production | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.production b/.env.production index 4577712..f8a939f 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,5 @@ -REACT_APP_BROKER_URL=https://connect.owlbear.rodeo -REACT_APP_ICE_SERVERS_URL=https://connect.owlbear.rodeo/iceservers +REACT_APP_BROKER_URL=https://test.owlbear.rodeo +REACT_APP_ICE_SERVERS_URL=https://test.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 From 96450eb1d0a5c77116263644b0ab305f16b9f6f2 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 22 Jan 2021 06:15:44 +1100 Subject: [PATCH 05/15] Update .env.production --- .env.production | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 74b44a8454be3f169d73108408dd016ee0db4784 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 22 Jan 2021 15:55:06 +1100 Subject: [PATCH 06/15] Update .env.production --- .env.production | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From c49d46e04f793821f31b086381924cc2da12c46a Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 22 Jan 2021 20:25:39 +1100 Subject: [PATCH 07/15] Added custom fathom domain --- public/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index f9e20ed..416afd6 100644 --- a/public/index.html +++ b/public/index.html @@ -28,8 +28,8 @@ - - + + From cee3514e7188f54739cc762f17ed8cd2958861a0 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 22 Jan 2021 20:32:00 +1100 Subject: [PATCH 08/15] Added localhost to excluded fathom domains --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 416afd6..16cc9c9 100644 --- a/public/index.html +++ b/public/index.html @@ -28,7 +28,7 @@ - + From 493377233ccb8935b20027a0de0b7c5c2d7ee241 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sat, 23 Jan 2021 00:01:15 +1100 Subject: [PATCH 09/15] Removed strict null check from map and mapState --- src/network/NetworkedMapAndTokens.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/network/NetworkedMapAndTokens.js b/src/network/NetworkedMapAndTokens.js index dcd8dbd..063806a 100644 --- a/src/network/NetworkedMapAndTokens.js +++ b/src/network/NetworkedMapAndTokens.js @@ -428,19 +428,19 @@ function NetworkedMapAndTokens({ session }) { const canChangeMap = !isLoading; const canEditMapDrawing = - currentMap !== null && - currentMapState !== null && + currentMap && + currentMapState && (currentMapState.editFlags.includes("drawing") || currentMap.owner === userId); const canEditFogDrawing = - currentMap !== null && - currentMapState !== null && + currentMap && + currentMapState && (currentMapState.editFlags.includes("fog") || currentMap.owner === userId); const canEditNotes = - currentMap !== null && - currentMapState !== null && + currentMap && + currentMapState && (currentMapState.editFlags.includes("notes") || currentMap.owner === userId); @@ -448,8 +448,8 @@ function NetworkedMapAndTokens({ session }) { // If we have a map and state and have the token permission disabled // and are not the map owner if ( - currentMapState !== null && - currentMap !== null && + currentMapState && + currentMap && !currentMapState.editFlags.includes("tokens") && currentMap.owner !== userId ) { From b9d8a007e5c6b3273aec039b2843f57fcf728c1f Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sat, 23 Jan 2021 15:44:25 +1100 Subject: [PATCH 10/15] Optimized fog shapes to only include needed data --- src/components/map/MapFog.js | 2 +- src/database.js | 24 ++++++++++++++++++++++++ src/helpers/drawing.js | 7 ++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/components/map/MapFog.js b/src/components/map/MapFog.js index 16a82a9..f2096d6 100644 --- a/src/components/map/MapFog.js +++ b/src/components/map/MapFog.js @@ -314,7 +314,7 @@ function MapFog({ } else if (toolSettings.type === "toggle") { onShapesEdit( editingShapes.map((shape) => ({ - ...shape, + id: shape.id, visible: !shape.visible, })) ); 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 4731f4e..a88123b 100644 --- a/src/helpers/drawing.js +++ b/src/helpers/drawing.js @@ -211,11 +211,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); } From ead0558a3be1c20d1164a3a2fa204fb863831fbf Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sat, 23 Jan 2021 15:58:13 +1100 Subject: [PATCH 11/15] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b25dfa0..76ae3a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "owlbear-rodeo", - "version": "1.7.0 (preview)", + "version": "1.7.0", "private": true, "dependencies": { "@babylonjs/core": "^4.2.0", From 31f9af583abf09158c1a3f94f4a4fe66b390c61f Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sun, 24 Jan 2021 09:18:25 +1100 Subject: [PATCH 12/15] Added more logging to token put error --- src/contexts/TokenDataContext.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/contexts/TokenDataContext.js b/src/contexts/TokenDataContext.js index f94026d..70cb2c7 100644 --- a/src/contexts/TokenDataContext.js +++ b/src/contexts/TokenDataContext.js @@ -7,6 +7,7 @@ import DatabaseContext from "./DatabaseContext"; import DatabaseWorker from "worker-loader!../workers/DatabaseWorker"; // eslint-disable-line import/no-webpack-loader-syntax import { tokens as defaultTokens } from "../tokens"; +import { logError } from "../helpers/logging"; const TokenDataContext = React.createContext(); @@ -105,7 +106,17 @@ export function TokenDataProvider({ children }) { } async function putToken(token) { - await database.table("tokens").put(token); + console.log(token); + try { + await database.table("tokens").put(token); + } catch { + if (token?.file) { + const { file, ...rest } = token; + logError(`Unable to save token ${JSON.stringify(rest)}`); + } else { + logError(`Unable to save token ${token}`); + } + } setTokens((prevTokens) => { const newTokens = [...prevTokens]; const i = newTokens.findIndex((t) => t.id === token.id); From 6d548e6fffd84b7d2194d98589f6dee96eb4b233 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sun, 24 Jan 2021 09:20:32 +1100 Subject: [PATCH 13/15] Update TokenDataContext.js --- src/contexts/TokenDataContext.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/contexts/TokenDataContext.js b/src/contexts/TokenDataContext.js index 70cb2c7..9617e0c 100644 --- a/src/contexts/TokenDataContext.js +++ b/src/contexts/TokenDataContext.js @@ -106,7 +106,6 @@ export function TokenDataProvider({ children }) { } async function putToken(token) { - console.log(token); try { await database.table("tokens").put(token); } catch { From ae32068ccb272cb4ab4451109c5433538ab25f32 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sun, 24 Jan 2021 09:21:22 +1100 Subject: [PATCH 14/15] Update TokenDataContext.js --- src/contexts/TokenDataContext.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contexts/TokenDataContext.js b/src/contexts/TokenDataContext.js index 9617e0c..2b5641d 100644 --- a/src/contexts/TokenDataContext.js +++ b/src/contexts/TokenDataContext.js @@ -113,7 +113,7 @@ export function TokenDataProvider({ children }) { const { file, ...rest } = token; logError(`Unable to save token ${JSON.stringify(rest)}`); } else { - logError(`Unable to save token ${token}`); + logError(`Unable to save token ${JSON.stringify(token)}`); } } setTokens((prevTokens) => { From 1c143f546421eacaa5b1ffca07ec73d90f59fa72 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Sun, 24 Jan 2021 17:50:52 +1100 Subject: [PATCH 15/15] Moved token request to DB and added sanity check to putToken --- src/contexts/TokenDataContext.js | 18 +++++++----------- src/network/NetworkedMapAndTokens.js | 17 +++++++++++------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/contexts/TokenDataContext.js b/src/contexts/TokenDataContext.js index 2b5641d..bd7caeb 100644 --- a/src/contexts/TokenDataContext.js +++ b/src/contexts/TokenDataContext.js @@ -7,7 +7,6 @@ import DatabaseContext from "./DatabaseContext"; import DatabaseWorker from "worker-loader!../workers/DatabaseWorker"; // eslint-disable-line import/no-webpack-loader-syntax import { tokens as defaultTokens } from "../tokens"; -import { logError } from "../helpers/logging"; const TokenDataContext = React.createContext(); @@ -106,16 +105,7 @@ export function TokenDataProvider({ children }) { } async function putToken(token) { - try { - await database.table("tokens").put(token); - } catch { - if (token?.file) { - const { file, ...rest } = token; - logError(`Unable to save token ${JSON.stringify(rest)}`); - } else { - logError(`Unable to save token ${JSON.stringify(token)}`); - } - } + await database.table("tokens").put(token); setTokens((prevTokens) => { const newTokens = [...prevTokens]; const i = newTokens.findIndex((t) => t.id === token.id); @@ -157,6 +147,11 @@ export function TokenDataProvider({ children }) { return tokens.find((token) => token.id === tokenId); } + 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) => { @@ -176,6 +171,7 @@ export function TokenDataProvider({ children }) { getToken, tokensById, tokensLoading, + getTokenFromDB, }; return ( diff --git a/src/network/NetworkedMapAndTokens.js b/src/network/NetworkedMapAndTokens.js index 063806a..be7b4d5 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, getMapFromDB, updateMapState } = useContext( MapDataContext ); @@ -311,7 +313,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, @@ -375,19 +376,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(); } }