Add world sizes for all platforms

This commit is contained in:
Natsumi
2024-08-02 09:46:04 +12:00
parent 29d3f85a08
commit 1d09785896
5 changed files with 90 additions and 65 deletions

View File

@@ -18073,8 +18073,8 @@ speechSynthesis.getVoices();
avatarScalingDisabled: false,
inCache: false,
cacheSize: '',
fileCreatedAt: '',
fileSize: ''
bundleSizes: [],
lastUpdated: ''
};
$app.data.currentInstanceLocation = {};
@@ -18093,8 +18093,8 @@ speechSynthesis.getVoices();
avatarScalingDisabled: false,
inCache: false,
cacheSize: '',
fileCreatedAt: '',
fileSize: ''
bundleSizes: [],
lastUpdated: ''
};
this.currentInstanceLocation = {};
} else if (instanceId !== this.currentInstanceLocation.tag) {
@@ -18107,8 +18107,8 @@ speechSynthesis.getVoices();
avatarScalingDisabled: false,
inCache: false,
cacheSize: '',
fileCreatedAt: '',
fileSize: ''
bundleSizes: [],
lastUpdated: ''
};
var L = API.parseLocation(instanceId);
this.currentInstanceLocation = L;
@@ -18132,12 +18132,9 @@ speechSynthesis.getVoices();
).toFixed(2)} MB`;
}
});
this.getBundleDateSize(args.ref).then(
({ createdAt, fileSize }) => {
this.currentInstanceWorld.fileCreatedAt = createdAt;
this.currentInstanceWorld.fileSize = fileSize;
}
);
this.getBundleDateSize(args.ref).then((bundleSizes) => {
this.currentInstanceWorld.bundleSizes = bundleSizes;
});
return args;
});
} else {
@@ -18766,8 +18763,8 @@ speechSynthesis.getVoices();
avatarScalingDisabled: false,
rooms: [],
treeData: [],
fileCreatedAt: '',
fileSize: '',
bundleSizes: [],
lastUpdated: '',
inCache: false,
cacheSize: 0,
cacheLocked: false,
@@ -18814,61 +18811,76 @@ speechSynthesis.getVoices();
});
}
}
if (D.fileSize === 'Loading') {
$app.getBundleDateSize(ref)
.then(({ createdAt, fileSize }) => {
D.fileCreatedAt = createdAt;
if (fileSize) {
D.fileSize = fileSize;
} else {
D.fileSize = 'Error';
}
})
.catch(() => {
D.fileSize = 'Error';
});
if (D.bundleSizes.length === 0) {
$app.getBundleDateSize(ref).then((bundleSizes) => {
D.bundleSizes = bundleSizes;
});
}
});
$app.methods.getBundleDateSize = async function (ref) {
var assetUrl = '';
var createdAt = '';
var fileSize = '';
var bundleSizes = [];
for (let i = ref.unityPackages.length - 1; i > -1; i--) {
var unityPackage = ref.unityPackages[i];
if (unityPackage.variant && unityPackage.variant !== 'standard') {
continue;
}
if (
unityPackage.platform === 'standalonewindows' &&
this.compareUnityVersion(unityPackage.unitySortNumber)
) {
assetUrl = unityPackage.assetUrl;
break;
if (!this.compareUnityVersion(unityPackage.unitySortNumber)) {
continue;
}
var platform = unityPackage.platform;
if (bundleSizes[platform]) {
continue;
}
var assetUrl = unityPackage.assetUrl;
var fileId = extractFileId(assetUrl);
var fileVersion = parseInt(extractFileVersion(assetUrl), 10);
if (!fileId) {
continue;
}
}
var fileId = extractFileId(assetUrl);
var fileVersion = parseInt(extractFileVersion(assetUrl), 10);
if (fileId) {
var args = await API.getBundles(fileId);
if (
typeof args.json !== 'undefined' &&
typeof args.json.versions !== 'undefined'
) {
var { versions } = args.json;
for (let i = versions.length - 1; i > -1; i--) {
var version = versions[i];
if (version.version === fileVersion) {
createdAt = version.created_at;
fileSize = `${(
version.file.sizeInBytes / 1048576
).toFixed(2)} MB`;
break;
if (!args?.json?.versions) {
continue;
}
var { versions } = args.json;
for (let j = versions.length - 1; j > -1; j--) {
var version = versions[j];
if (version.version === fileVersion) {
var createdAt = version.created_at;
var fileSize = `${(
version.file.sizeInBytes / 1048576
).toFixed(2)} MB`;
bundleSizes[platform] = { createdAt, fileSize };
// update world dialog
if (this.worldDialog.id === ref.id) {
this.worldDialog.bundleSizes[platform] =
bundleSizes[platform];
if (this.worldDialog.lastUpdated < version.created_at) {
this.worldDialog.lastUpdated = version.created_at;
}
}
// update player list
if (this.currentInstanceLocation.worldId === ref.id) {
this.currentInstanceWorld.bundleSizes[platform] =
bundleSizes[platform];
if (
this.currentInstanceWorld.lastUpdated <
version.created_at
) {
this.currentInstanceWorld.lastUpdated =
version.created_at;
}
}
break;
}
}
}
return { createdAt, fileSize };
return bundleSizes;
};
API.$on('FAVORITE', function (args) {
@@ -18899,8 +18911,8 @@ speechSynthesis.getVoices();
D.id = L.worldId;
D.$location = L;
D.treeData = [];
D.fileCreatedAt = '';
D.fileSize = 'Loading';
D.bundleSizes = [];
D.lastUpdated = '';
D.visible = true;
D.loading = true;
D.inCache = false;