Change map state drawShapes and fogShapes name
This commit is contained in:
parent
d1e62e850a
commit
b300418d78
@ -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") {
|
||||
|
@ -113,7 +113,7 @@ function MapContols({
|
||||
const disabledSettings: Partial<Record<keyof Settings, string[]>> = {
|
||||
drawing: [],
|
||||
};
|
||||
if (mapState && isEmpty(mapState.drawShapes)) {
|
||||
if (mapState && isEmpty(mapState.drawings)) {
|
||||
disabledSettings.drawing?.push("erase");
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -252,9 +252,9 @@ function SelectionMenu({
|
||||
data: {
|
||||
tokens: {},
|
||||
notes: {},
|
||||
drawShapes: {},
|
||||
drawings: {},
|
||||
editFlags: [],
|
||||
fogShapes: {},
|
||||
fogs: {},
|
||||
mapId: mapState.mapId,
|
||||
},
|
||||
};
|
||||
|
@ -55,8 +55,8 @@ const MapDataContext =
|
||||
|
||||
const defaultMapState: Omit<MapState, "mapId"> = {
|
||||
tokens: {},
|
||||
drawShapes: {},
|
||||
fogShapes: {},
|
||||
drawings: {},
|
||||
fogs: {},
|
||||
// Flags to determine what other people can edit
|
||||
editFlags: ["drawing", "tokens", "notes", "fog"],
|
||||
notes: {},
|
||||
|
@ -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") {
|
||||
|
@ -55,8 +55,8 @@ export function getDefaultMaps(userId: string): {
|
||||
const state: MapState = {
|
||||
mapId: id,
|
||||
tokens: {},
|
||||
drawShapes: {},
|
||||
fogShapes: {},
|
||||
drawings: {},
|
||||
fogs: {},
|
||||
editFlags: ["drawing", "tokens", "notes"],
|
||||
notes: {},
|
||||
};
|
||||
|
@ -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<EditFlag>;
|
||||
notes: Notes;
|
||||
mapId: string;
|
||||
|
@ -847,9 +847,40 @@ export const versions: Record<number, VersionCallback> = {
|
||||
});
|
||||
});
|
||||
},
|
||||
// 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
|
||||
|
@ -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: {
|
||||
|
Loading…
Reference in New Issue
Block a user