input-output-hk / lace

The Lace Wallet.
https://lace.io
Apache License 2.0
16 stars 5 forks source link

fix(extension): debounce on CIP-30 endpoint calls now starts after first event #1458

Closed AngelCastilloB closed 1 month ago

AngelCastilloB commented 1 month ago

Checklist


Currently Lace uses p-debounce to throttle CIP-30 API calls. However p-debounce by defaults

Returns a function that delays calling fn until after wait milliseconds have elapsed since the last time it was called.

Which means it will add the delay even to the first function call, this is introducing a very noticeable delay on the UI giivng the imprecision that the extension runs slow.

Proposed solution

Set the option:

before
Type: boolean
Default: false

Call the fn on the [leading edge of the timeout](https://css-tricks.com/debouncing-throttling-explained-examples/#article-header-id-1). Meaning immediately, instead of waiting for wait milliseconds.

This makes the denounce to only apply to function calls in rapid succession.

pczeglik-iohk commented 1 month ago

Allure Report

allure-report-publisher generated test report!

processReports: ✅ test report for 30eab974 passed failed skipped flaky total result
Total 32 0 4 0 36
sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
4 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.1% Duplication on New Code

See analysis details on SonarCloud