Added basic persistance to notes

This commit is contained in:
Mitchell McCaffrey
2020-11-03 17:15:39 +11:00
parent 84af4c5845
commit 6c1d952855
5 changed files with 107 additions and 26 deletions
+21
View File
@@ -167,6 +167,17 @@ function NetworkedMapAndTokens({ session }) {
session.send("mapFogIndex", index);
}
function handleNoteAdd(note) {
setCurrentMapState((prevMapState) => ({
...prevMapState,
notes: {
...prevMapState.notes,
[note.id]: note,
},
}));
session.send("mapNoteAdd", note);
}
/**
* Token state
*/
@@ -395,6 +406,15 @@ function NetworkedMapAndTokens({ session }) {
fogDrawActionIndex: data,
}));
}
if (id === "mapNoteAdd" && currentMapState) {
setCurrentMapState((prevMapState) => ({
...prevMapState,
notes: {
...prevMapState.notes,
[data.id]: data,
},
}));
}
}
function handlePeerDataProgress({ id, total, count }) {
@@ -460,6 +480,7 @@ function NetworkedMapAndTokens({ session }) {
onFogDraw={handleFogDraw}
onFogDrawUndo={handleFogDrawUndo}
onFogDrawRedo={handleFogDrawRedo}
onMapNoteAdd={handleNoteAdd}
allowMapDrawing={canEditMapDrawing}
allowFogDrawing={canEditFogDrawing}
allowMapChange={canChangeMap}