diff --git a/src/components/map/Map.tsx b/src/components/map/Map.tsx index 140a77b..9f31ab5 100644 --- a/src/components/map/Map.tsx +++ b/src/components/map/Map.tsx @@ -104,8 +104,8 @@ function Map({ })); } - const drawShapes = Object.values(mapState?.drawShapes || {}); - const fogShapes = Object.values(mapState?.fogShapes || {}); + const drawShapes = Object.values(mapState?.drawings || {}); + const fogShapes = Object.values(mapState?.fogs || {}); function handleToolAction(action: string) { if (action === "eraseAll") { diff --git a/src/components/map/MapControls.tsx b/src/components/map/MapControls.tsx index 5d9217b..733447f 100644 --- a/src/components/map/MapControls.tsx +++ b/src/components/map/MapControls.tsx @@ -113,7 +113,7 @@ function MapContols({ const disabledSettings: Partial> = { drawing: [], }; - if (mapState && isEmpty(mapState.drawShapes)) { + if (mapState && isEmpty(mapState.drawings)) { disabledSettings.drawing?.push("erase"); } diff --git a/src/components/map/MapEditBar.tsx b/src/components/map/MapEditBar.tsx index 201ae51..84a9942 100644 --- a/src/components/map/MapEditBar.tsx +++ b/src/components/map/MapEditBar.tsx @@ -52,8 +52,8 @@ function MapEditBar({ for (let state of selectedMapStates) { if ( Object.values(state.tokens).length > 0 || - Object.values(state.drawShapes).length > 0 || - Object.values(state.fogShapes).length > 0 || + Object.values(state.drawings).length > 0 || + Object.values(state.fogs).length > 0 || Object.values(state.notes).length > 0 ) { _hasMapState = true; diff --git a/src/components/selection/SelectionMenu.tsx b/src/components/selection/SelectionMenu.tsx index 755c1db..644c48d 100644 --- a/src/components/selection/SelectionMenu.tsx +++ b/src/components/selection/SelectionMenu.tsx @@ -252,9 +252,9 @@ function SelectionMenu({ data: { tokens: {}, notes: {}, - drawShapes: {}, + drawings: {}, editFlags: [], - fogShapes: {}, + fogs: {}, mapId: mapState.mapId, }, }; diff --git a/src/contexts/MapDataContext.tsx b/src/contexts/MapDataContext.tsx index 7ae062e..9bdfac5 100644 --- a/src/contexts/MapDataContext.tsx +++ b/src/contexts/MapDataContext.tsx @@ -55,8 +55,8 @@ const MapDataContext = const defaultMapState: Omit = { tokens: {}, - drawShapes: {}, - fogShapes: {}, + drawings: {}, + fogs: {}, // Flags to determine what other people can edit editFlags: ["drawing", "tokens", "notes", "fog"], notes: {}, diff --git a/src/hooks/useMapActions.ts b/src/hooks/useMapActions.ts index f57c4ae..37d3065 100644 --- a/src/hooks/useMapActions.ts +++ b/src/hooks/useMapActions.ts @@ -50,9 +50,9 @@ function useMapActions( ): MapState { for (let mapAction of actions) { if (mapAction.type === "drawings") { - mapState.drawShapes = mapAction.action.execute(mapState.drawShapes); + mapState.drawings = mapAction.action.execute(mapState.drawings); } else if (mapAction.type === "fogs") { - mapState.fogShapes = mapAction.action.execute(mapState.fogShapes); + mapState.fogs = mapAction.action.execute(mapState.fogs); } else if (mapAction.type === "tokens") { mapState.tokens = mapAction.action.execute(mapState.tokens); } else if (mapAction.type === "notes") { @@ -68,9 +68,9 @@ function useMapActions( ): MapState { for (let mapAction of actions) { if (mapAction.type === "drawings") { - mapState.drawShapes = mapAction.action.undo(mapState.drawShapes); + mapState.drawings = mapAction.action.undo(mapState.drawings); } else if (mapAction.type === "fogs") { - mapState.fogShapes = mapAction.action.undo(mapState.fogShapes); + mapState.fogs = mapAction.action.undo(mapState.fogs); } else if (mapAction.type === "tokens") { mapState.tokens = mapAction.action.undo(mapState.tokens); } else if (mapAction.type === "notes") { diff --git a/src/maps/index.ts b/src/maps/index.ts index 8ec8d3e..fc75ef2 100644 --- a/src/maps/index.ts +++ b/src/maps/index.ts @@ -55,8 +55,8 @@ export function getDefaultMaps(userId: string): { const state: MapState = { mapId: id, tokens: {}, - drawShapes: {}, - fogShapes: {}, + drawings: {}, + fogs: {}, editFlags: ["drawing", "tokens", "notes"], notes: {}, }; diff --git a/src/types/MapState.ts b/src/types/MapState.ts index 0caeed8..8b3ec72 100644 --- a/src/types/MapState.ts +++ b/src/types/MapState.ts @@ -7,8 +7,8 @@ export type EditFlag = "drawing" | "tokens" | "notes" | "fog"; export type MapState = { tokens: TokenStates; - drawShapes: DrawingState; - fogShapes: FogState; + drawings: DrawingState; + fogs: FogState; editFlags: Array; notes: Notes; mapId: string; diff --git a/src/upgrade.ts b/src/upgrade.ts index c1b7c44..1c6881b 100644 --- a/src/upgrade.ts +++ b/src/upgrade.ts @@ -847,9 +847,40 @@ export const versions: Record = { }); }); }, + // v1.10.0 - Delete groups again + 38(v, onUpgrade) { + v.stores({}).upgrade((tx) => { + onUpgrade?.(38); + tx.table("maps") + .toCollection() + .modify((map) => { + delete map.group; + }); + tx.table("tokens") + .toCollection() + .modify((token) => { + delete token.group; + }); + }); + }, + // v1.10.0 - Rename drawShapes and fogShapes in state + 39(v, onUpgrade) { + v.stores({}).upgrade((tx) => { + onUpgrade?.(39); + tx.table("states") + .toCollection() + .modify((state) => { + state.drawings = state.drawShapes; + state.fogs = state.fogShapes; + + delete state.drawShapes; + delete state.fogShapes; + }); + }); + }, }; -export const latestVersion = 37; +export const latestVersion = 39; /** * Load versions onto a database up to a specific version number diff --git a/src/validators/MapState.ts b/src/validators/MapState.ts index 751d92f..7e1e87f 100644 --- a/src/validators/MapState.ts +++ b/src/validators/MapState.ts @@ -15,10 +15,10 @@ export const MapStateSchema: any = { tokens: { $ref: "#/definitions/TokenStates", }, - drawShapes: { + drawings: { $ref: "#/definitions/DrawingState", }, - fogShapes: { + fogs: { $ref: "#/definitions/FogState", }, editFlags: { @@ -35,14 +35,7 @@ export const MapStateSchema: any = { type: "string", }, }, - required: [ - "drawShapes", - "editFlags", - "fogShapes", - "mapId", - "notes", - "tokens", - ], + required: ["drawings", "editFlags", "fogs", "mapId", "notes", "tokens"], type: "object", definitions: { TokenStates: {