user преди 6 години
родител
ревизия
b0c8503ebd
променени са 3 файла, в които са добавени 6 реда и са изтрити 12 реда
  1. 2 5
      lib/index.js
  2. 1 1
      lib/index.js.map
  3. 3 6
      src/index.ts

+ 2 - 5
lib/index.js

@@ -345,13 +345,9 @@ class BankClient {
         return __awaiter(this, void 0, void 0, function* () {
             yield this.subscribePrivate(address, topic, () => {
                 // console.log('websocket connected');
-            }, (msg) => __awaiter(this, void 0, void 0, function* () {
-                console.log('Got new item notification', msg);
+            }, () => __awaiter(this, void 0, void 0, function* () {
                 yield agentUpdate();
             }));
-            setTimeout(() => __awaiter(this, void 0, void 0, function* () {
-                yield agentUpdate();
-            }), 0);
             const agentUpdate = () => __awaiter(this, void 0, void 0, function* () {
                 const agentConfig = (yield storage.get('config')) || {};
                 const items = yield this.retrievePrivate(address, topic);
@@ -374,6 +370,7 @@ class BankClient {
                 }
                 console.log('Finished checking for items');
             });
+            yield agentUpdate();
         });
     }
     connectWebsocket(peerAddr, topic, connectCallback, messageCallback) {

Файловите разлики са ограничени, защото са твърде много
+ 1 - 1
lib/index.js.map


+ 3 - 6
src/index.ts

@@ -339,16 +339,11 @@ export class BankClient {
       () => {
         // console.log('websocket connected');
       },
-      async (msg) => {
-        console.log('Got new item notification', msg);
+      async () => {
         await agentUpdate();
       }
     );
 
-    setTimeout(async () => {
-      await agentUpdate();
-    }, 0);
-
     const agentUpdate = async () => {
       const agentConfig = (await storage.get('config')) || {};
       const items = await this.retrievePrivate(address, topic);
@@ -371,6 +366,8 @@ export class BankClient {
       }
       console.log('Finished checking for items');
     }
+
+    await agentUpdate();
   }
 
   private connectWebsocket(peerAddr: string, topic: string, connectCallback: () => void, messageCallback: (data: any) => void) {