Fixed bug with map setting changes not being synced over to players

This commit is contained in:
Mitchell McCaffrey 2020-07-17 19:22:12 +10:00
parent 6aa1f28c96
commit 8f9027c69f
2 changed files with 7 additions and 4 deletions

View File

@ -105,13 +105,12 @@ export function MapDataProvider({ children }) {
} }
async function updateMap(id, update) { async function updateMap(id, update) {
const change = { ...update, lastModified: Date.now() }; await database.table("maps").update(id, update);
await database.table("maps").update(id, change);
setMaps((prevMaps) => { setMaps((prevMaps) => {
const newMaps = [...prevMaps]; const newMaps = [...prevMaps];
const i = newMaps.findIndex((map) => map.id === id); const i = newMaps.findIndex((map) => map.id === id);
if (i > -1) { if (i > -1) {
newMaps[i] = { ...newMaps[i], ...change }; newMaps[i] = { ...newMaps[i], ...update };
} }
return newMaps; return newMaps;
}); });

View File

@ -216,7 +216,11 @@ function SelectMapModal({
const [mapStateSettingChanges, setMapStateSettingChanges] = useState({}); const [mapStateSettingChanges, setMapStateSettingChanges] = useState({});
function handleMapSettingsChange(key, value) { function handleMapSettingsChange(key, value) {
setMapSettingChanges((prevChanges) => ({ ...prevChanges, [key]: value })); setMapSettingChanges((prevChanges) => ({
...prevChanges,
[key]: value,
lastModified: Date.now(),
}));
} }
function handleMapStateSettingsChange(key, value) { function handleMapStateSettingsChange(key, value) {