Add thumbnail sending to assets for map grid

This commit is contained in:
Mitchell McCaffrey
2021-04-29 15:44:57 +10:00
parent 0ccee84cbf
commit 71edf5c5c5
6 changed files with 38 additions and 48 deletions
+11 -10
View File
@@ -65,14 +65,6 @@ function NetworkedMapAndTokens({ session }) {
async function loadAssetManifestFromMap(map, mapState) {
const assets = {};
const { owner } = map;
if (map.type === "file") {
const qualityId = map.resolutions[map.quality];
if (qualityId) {
assets[qualityId] = { id: qualityId, owner };
} else {
assets[map.file] = { id: map.file, owner };
}
}
let processedTokens = new Set();
for (let tokenState of Object.values(mapState.tokens)) {
if (
@@ -84,6 +76,15 @@ function NetworkedMapAndTokens({ session }) {
assets[tokenState.file] = { id: tokenState.file, owner };
}
}
if (map.type === "file") {
assets[map.thumbnail] = { id: map.thumbnail, owner };
const qualityId = map.resolutions[map.quality];
if (qualityId) {
assets[qualityId] = { id: qualityId, owner };
} else {
assets[map.file] = { id: map.file, owner };
}
}
setAssetManifest({ mapId: map.id, assets }, true, true);
}
@@ -144,8 +145,8 @@ function NetworkedMapAndTokens({ session }) {
if (cachedAsset) {
requestingAssetsRef.current.delete(asset.id);
} else {
session.sendTo(owner.sessionId, "assetRequest", asset.id);
assetLoadStart(asset.id);
session.sendTo(owner.sessionId, "assetRequest", asset);
}
}
}
@@ -381,7 +382,7 @@ function NetworkedMapAndTokens({ session }) {
useEffect(() => {
async function handlePeerData({ id, data, reply }) {
if (id === "assetRequest") {
const asset = await getAsset(data);
const asset = await getAsset(data.id);
reply("assetResponse", asset, undefined, asset.id);
}