Implement asset clear cache and remove cache when upgrading to 1.9
This commit is contained in:
parent
04cf5687dd
commit
f844199172
@ -559,7 +559,7 @@ const versions = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// v1.9.0 - Move tokens to use more defaults and add token outline
|
// v1.9.0 - Move tokens to use more defaults and add token outline to tokens
|
||||||
28(v) {
|
28(v) {
|
||||||
v.stores({}).upgrade((tx) => {
|
v.stores({}).upgrade((tx) => {
|
||||||
tx.table("tokens")
|
tx.table("tokens")
|
||||||
@ -576,7 +576,7 @@ const versions = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// v1.9.0 - Move tokens to use more defaults and add token outline
|
// v1.9.0 - Move tokens to use more defaults and add token outline to token states
|
||||||
29(v) {
|
29(v) {
|
||||||
v.stores({}).upgrade((tx) => {
|
v.stores({}).upgrade((tx) => {
|
||||||
tx.table("states")
|
tx.table("states")
|
||||||
@ -612,6 +612,20 @@ const versions = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// v1.9.0 - Remove maps not owned by user as cache is now done on the asset level
|
||||||
|
30(v) {
|
||||||
|
v.stores({}).upgrade(async (tx) => {
|
||||||
|
const userId = (await tx.table("user").get("userId")).value;
|
||||||
|
tx.table("maps").where("owner").notEqual(userId).delete();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// v1.9.0 - Remove tokens not owned by user as cache is now done on the asset level
|
||||||
|
31(v) {
|
||||||
|
v.stores({}).upgrade(async (tx) => {
|
||||||
|
const userId = (await tx.table("user").get("userId")).value;
|
||||||
|
tx.table("tokens").where("owner").notEqual(userId).delete();
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const latestVersion = 29;
|
const latestVersion = 29;
|
||||||
|
@ -66,26 +66,24 @@ function SettingsModal({ isOpen, onRequestClose }) {
|
|||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
// Clear saved settings
|
// Clear saved settings
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
// Clear map cache
|
|
||||||
await database.table("maps").where("owner").notEqual(userId).delete();
|
const assets = await database
|
||||||
// Find all other peoples tokens who aren't benig used in a map state and delete them
|
.table("assets")
|
||||||
const tokens = await database
|
|
||||||
.table("tokens")
|
|
||||||
.where("owner")
|
.where("owner")
|
||||||
.notEqual(userId)
|
.notEqual(userId)
|
||||||
.toArray();
|
.toArray();
|
||||||
const states = await database.table("states").toArray();
|
const states = await database.table("states").toArray();
|
||||||
for (let token of tokens) {
|
for (let asset of assets) {
|
||||||
let inUse = false;
|
let inUse = false;
|
||||||
for (let state of states) {
|
for (let state of states) {
|
||||||
for (let tokenState of Object.values(state.tokens)) {
|
for (let tokenState of Object.values(state.tokens)) {
|
||||||
if (token.id === tokenState.tokenId) {
|
if (tokenState.type === "file" && asset.id === tokenState.file) {
|
||||||
inUse = true;
|
inUse = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!inUse) {
|
if (!inUse) {
|
||||||
database.table("tokens").delete(token.id);
|
await database.table("assets").delete(asset.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
Loading…
Reference in New Issue
Block a user