Added automatic cache invalidation for maps and tokens

This commit is contained in:
Mitchell McCaffrey
2020-09-11 16:56:40 +10:00
parent 529fd2caae
commit e92c561a3a
7 changed files with 120 additions and 9 deletions

View File

@@ -149,6 +149,7 @@ function SelectMapModal({
id: shortid.generate(),
created: Date.now(),
lastModified: Date.now(),
lastUsed: Date.now(),
owner: userId,
...defaultMapProps,
});
@@ -213,7 +214,13 @@ function SelectMapModal({
}
if (selectedMapId) {
await applyMapChanges();
onMapChange(selectedMapWithChanges, selectedMapStateWithChanges);
// Update last used for cache invalidation
const lastUsed = Date.now();
await updateMap(selectedMapId, { lastUsed });
onMapChange(
{ ...selectedMapWithChanges, lastUsed },
selectedMapStateWithChanges
);
} else {
onMapChange(null, null);
}