Fix for flosight/floBlockchainAPI update

This commit is contained in:
sairajzero 2023-05-12 01:12:04 +05:30
parent 1628663a61
commit 91eaaa74e7

View File

@ -1056,13 +1056,14 @@
return reject("Not an valid address"); return reject("Not an valid address");
let last_key = `${floGlobals.application}|${user_floID}`; let last_key = `${floGlobals.application}|${user_floID}`;
compactIDB.readData("lastTx", last_key, floDapps.root).then(lastTx => { compactIDB.readData("lastTx", last_key, floDapps.root).then(lastTx => {
floBlockchainAPI.readData(user_floID, { var query_options = { pattern: floGlobals.application, tx: true };
ignoreOld: lastTx, if (typeof lastTx == 'number') //lastTx is tx count (*backward support)
pattern: floGlobals.application, query_options.ignoreOld = lastTx;
tx: true //need tx-time and txid for key construction else if (typeof lastTx == 'string') //lastTx is txid of last tx
}).then(result => { query_options.after = lastTx;
for (var i = result.data.length - 1; i >= 0; i--) { floBlockchainAPI.readData(user_floID, query_options).then(result => {
let tx = result.data[i], for (var i = result.items.length - 1; i >= 0; i--) {
let tx = result.items[i],
content = JSON.parse(tx.data)[floGlobals.application]; content = JSON.parse(tx.data)[floGlobals.application];
if (!(content instanceof Object)) if (!(content instanceof Object))
continue; continue;
@ -1073,7 +1074,7 @@
data: content data: content
}, key); }, key);
} }
compactIDB.writeData("lastTx", result.totalTxs, last_key, floDapps.root); compactIDB.writeData("lastTx", result.lastItem, last_key, floDapps.root);
resolve(true); resolve(true);
}).catch(error => reject(error)) }).catch(error => reject(error))
}).catch(error => reject(error)) }).catch(error => reject(error))