mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:08:00 +02:00
separate getAsset fail/then handlers
This commit is contained in:
parent
16ca0eebed
commit
76cbc4ee55
1 changed files with 4 additions and 3 deletions
|
@ -236,11 +236,12 @@ void AssetScriptingInterface::getAsset(QScriptValue options, QScriptValue scope,
|
||||||
Promise fetched = jsPromiseReady(makePromise("fetched"), scope, callback);
|
Promise fetched = jsPromiseReady(makePromise("fetched"), scope, callback);
|
||||||
Promise mapped = makePromise("mapped");
|
Promise mapped = makePromise("mapped");
|
||||||
|
|
||||||
mapped->ready([=](QString error, QVariantMap result) {
|
mapped->fail(fetched);
|
||||||
|
mapped->then([=](QVariantMap result) {
|
||||||
QString hash = result.value("hash").toString();
|
QString hash = result.value("hash").toString();
|
||||||
QString url = result.value("url").toString();
|
QString url = result.value("url").toString();
|
||||||
if (!error.isEmpty() || !AssetUtils::isValidHash(hash)) {
|
if (!AssetUtils::isValidHash(hash)) {
|
||||||
fetched->reject(error.isEmpty() ? "internal hash error: " + hash : error, result);
|
fetched->reject("internal hash error: " + hash, result);
|
||||||
} else {
|
} else {
|
||||||
Promise promise = loadAsset(hash, decompress, responseType);
|
Promise promise = loadAsset(hash, decompress, responseType);
|
||||||
promise->mixin(result);
|
promise->mixin(result);
|
||||||
|
|
Loading…
Reference in a new issue