fix(amm): complete repeated context refreshes

This commit is contained in:
Ricardo Guilherme Schmidt
2026-07-18 19:55:15 -03:00
parent 80e3a7da62
commit 56178fb6af
2 changed files with 22 additions and 1 deletions
+3 -1
View File
@@ -253,8 +253,10 @@ void AmmUiBackend::refreshNewPositionContext(QVariantMap request)
m_newPosition->contextAsync(
request, m_network.snapshot(), isWalletOpen(), refreshWalletAccounts,
[this, generation](QVariantMap result) {
if (generation == m_contextGeneration)
if (generation == m_contextGeneration) {
result.insert(QStringLiteral("requestId"), generation);
setNewPositionContext(std::move(result));
}
});
}
+19
View File
@@ -35,6 +35,7 @@ TestCase {
"feeTiers": []
})
property int contextRefreshCalls: 0
property int contextRequestId: 0
property int submitCalls: 0
property var lastContextRefreshRequest: ({})
@@ -54,6 +55,9 @@ TestCase {
function refreshNewPositionContext(request) {
++contextRefreshCalls
lastContextRefreshRequest = request
var result = JSON.parse(JSON.stringify(newPositionContext))
result.requestId = ++contextRequestId
newPositionContext = result
}
}
}
@@ -112,6 +116,21 @@ TestCase {
compare(page.flow.contextHints(true).refreshWalletAccounts, true)
}
function test_repeatedIdenticalContextCompletesRefresh() {
var backend = createTemporaryObject(backendComponent, testCase)
var page = createTemporaryObject(pageComponent, testCase, { "backend": backend })
verify(page)
page.flow.refreshContext(false)
tryCompare(page.flow, "contextLoading", false)
compare(backend.contextRequestId, 1)
page.flow.refreshContext(false)
tryCompare(page.flow, "contextLoading", false)
compare(backend.contextRequestId, 2)
compare(page.flow.newPositionContext.status, "ready")
}
function test_submitFailureKeepsReturnedFreshQuoteWithoutRequery() {
var backend = createTemporaryObject(backendComponent, testCase)
var page = createTemporaryObject(pageComponent, testCase, { "backend": backend })