Support custom instance names

This commit is contained in:
Natsumi
2025-09-28 11:35:49 +13:00
parent 81a51ad2fa
commit da3c12c15b
10 changed files with 148 additions and 50 deletions

View File

@@ -21,6 +21,35 @@ const instanceReq = {
});
},
/**
* @param {{worldId: string, instanceId: string}} params
* @returns {Promise<{json: any, ref: any, cache?: boolean, params}>}
*/
getCachedInstance(params) {
const instanceStore = useInstanceStore();
return new Promise((resolve, reject) => {
const ref = instanceStore.cachedInstances.get(
`${params.worldId}:${params.instanceId}`
);
if (typeof ref === 'undefined') {
instanceReq
.getInstance(params)
.then((args) => {
args.ref = instanceStore.applyInstance(args.json);
resolve(args);
})
.catch(reject);
} else {
resolve({
cache: true,
json: ref,
params,
ref
});
}
});
},
/**
* @type {import('../types/api/instance').CreateInstance}
*/