Added search and groups to token select, refactored map search and group

This commit is contained in:
Mitchell McCaffrey
2020-10-01 22:32:21 +10:00
parent 0174acbde0
commit f28d1b6690
17 changed files with 614 additions and 366 deletions

View File

@@ -143,6 +143,22 @@ export function MapDataProvider({ children }) {
});
}
async function updateMaps(ids, update) {
await Promise.all(
ids.map((id) => database.table("maps").update(id, update))
);
setMaps((prevMaps) => {
const newMaps = [...prevMaps];
for (let id of ids) {
const i = newMaps.findIndex((map) => map.id === id);
if (i > -1) {
newMaps[i] = { ...newMaps[i], ...update };
}
}
return newMaps;
});
}
async function updateMapState(id, update) {
await database.table("states").update(id, update);
setMapStates((prevMapStates) => {
@@ -218,6 +234,7 @@ export function MapDataProvider({ children }) {
removeMaps,
resetMap,
updateMap,
updateMaps,
updateMapState,
putMap,
getMap,