mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 16:02:26 +00:00
Fix NIP-07 timeout helper to preserve user gestures
This commit is contained in:
1 parent
fd62159e61
commit
8d7d7a86cf
1 file changed
+13
-4
+13
-4
@@ -62,10 +62,19 @@ function withNip07Timeout(operation) {
|
||||
}, NIP07_LOGIN_TIMEOUT_MS);
|
||||
});
|
||||
|
||||
return Promise.race([
|
||||
Promise.resolve().then(operation),
|
||||
timeoutPromise,
|
||||
]).finally(() => {
|
||||
let operationResult;
|
||||
try {
|
||||
operationResult = operation();
|
||||
} catch (err) {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
||||
const operationPromise = Promise.resolve(operationResult);
|
||||
|
||||
return Promise.race([operationPromise, timeoutPromise]).finally(() => {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user