mirror of
https://github.com/lubosz/overte.git
synced 2025-04-19 12:24:01 +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 mapped = makePromise("mapped");
|
||||
|
||||
mapped->ready([=](QString error, QVariantMap result) {
|
||||
mapped->fail(fetched);
|
||||
mapped->then([=](QVariantMap result) {
|
||||
QString hash = result.value("hash").toString();
|
||||
QString url = result.value("url").toString();
|
||||
if (!error.isEmpty() || !AssetUtils::isValidHash(hash)) {
|
||||
fetched->reject(error.isEmpty() ? "internal hash error: " + hash : error, result);
|
||||
if (!AssetUtils::isValidHash(hash)) {
|
||||
fetched->reject("internal hash error: " + hash, result);
|
||||
} else {
|
||||
Promise promise = loadAsset(hash, decompress, responseType);
|
||||
promise->mixin(result);
|
||||
|
|
Loading…
Reference in a new issue