[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: simplify alarm and check webR
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: simplify alarm and check webRequest without using 'in' |
Date: |
Thu, 28 Apr 2022 20:56:32 +0200 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 508f5d2e simplify alarm and check webRequest without using 'in'
508f5d2e is described below
commit 508f5d2ea7a0c83eeb35bfae08a514c7e23fd884
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Thu Apr 28 15:55:20 2022 -0300
simplify alarm and check webRequest without using 'in'
---
packages/taler-wallet-core/src/wallet.ts | 25 ----------------------
.../src/platform/chrome.ts | 24 +++++++++------------
2 files changed, 10 insertions(+), 39 deletions(-)
diff --git a/packages/taler-wallet-core/src/wallet.ts
b/packages/taler-wallet-core/src/wallet.ts
index 579710d4..96722aef 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -326,27 +326,6 @@ export interface RetryLoopOpts {
stopWhenDone?: boolean;
}
-/**
- * This iteration hint will keep incrementing while the taskLoop iteration.
- * If the hint does not match the current iteration it means that another
- * promises is also working or has done some work before.
- */
-let iterationHint = 0
-function thereIsAnotherPromiseWorking(iteration: number): boolean {
- if (iterationHint > iteration) {
- logger.trace(`some other promise is or has done some progress`);
- iterationHint = iteration;
- //we know that another promise did some work but don't know if still active
- //so we take ownership and do work
- } else if (iterationHint < iteration) {
- //another promise take ownership that means that our time has come to an
end
- return true
- }
- // increment the hint to match the next loop
- iterationHint++
- return false
-}
-
/**
* Main retry loop of the wallet.
*
@@ -357,10 +336,6 @@ async function runTaskLoop(
opts: RetryLoopOpts = {},
): Promise<void> {
for (let iteration = 0; !ws.stopped; iteration++) {
- if (thereIsAnotherPromiseWorking(iteration)) {
- logger.trace(`another promise is working, we just need one`);
- return;
- }
const pending = await getPendingOperations(ws);
logger.trace(`pending operations: ${j2s(pending)}`);
let numGivingLiveness = 0;
diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts
b/packages/taler-wallet-webextension/src/platform/chrome.ts
index 900470df..e4ebfbae 100644
--- a/packages/taler-wallet-webextension/src/platform/chrome.ts
+++ b/packages/taler-wallet-webextension/src/platform/chrome.ts
@@ -51,11 +51,11 @@ function keepAlive(callback: any): void {
chrome.alarms.onAlarm.addListener((a) => {
logger.trace(`kee p alive alarm: ${a.name}`)
- callback()
+ // callback()
})
- } else {
- callback();
+ // } else {
}
+ callback();
}
@@ -331,29 +331,25 @@ function registerTalerHeaderListener(callback: (tabId:
number, url: string) => v
getPermissionsApi().containsHostPermissions().then(result => {
//if there is a handler already, remove it
if (
- "webRequest" in chrome &&
- "onHeadersReceived" in chrome.webRequest &&
prevHeaderListener &&
- chrome.webRequest.onHeadersReceived.hasListener(prevHeaderListener)
+ chrome?.webRequest?.onHeadersReceived?.hasListener(prevHeaderListener)
) {
chrome.webRequest.onHeadersReceived.removeListener(prevHeaderListener);
}
//if the result was positive, add the headerListener
if (result) {
- chrome.webRequest.onHeadersReceived.addListener(
+ chrome?.webRequest?.onHeadersReceived?.addListener(
headerListener,
{ urls: ["<all_urls>"] },
["responseHeaders"],
);
}
//notify the browser about this change, this operation is expensive
- if ("webRequest" in chrome) {
- chrome.webRequest.handlerBehaviorChanged(() => {
- if (chrome.runtime.lastError) {
- console.error(JSON.stringify(chrome.runtime.lastError));
- }
- });
- }
+ chrome?.webRequest?.handlerBehaviorChanged(() => {
+ if (chrome.runtime.lastError) {
+ console.error(JSON.stringify(chrome.runtime.lastError));
+ }
+ });
});
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: simplify alarm and check webRequest without using 'in',
gnunet <=