user 6 gadi atpakaļ
vecāks
revīzija
dde428114f
4 mainītis faili ar 12 papildinājumiem un 6 dzēšanām
  1. 1 1
      lib/index.d.ts
  2. 5 2
      lib/index.js
  3. 1 1
      lib/index.js.map
  4. 5 2
      src/index.ts

+ 1 - 1
lib/index.d.ts

@@ -29,7 +29,7 @@ export declare class BankClient {
     appendPrivate(peerAddr: string, topic: string, hash?: string, replaceHash?: string, deleteHash?: string): Promise<void>;
     retrievePrivate(peerAddr: string, topic: string): Promise<string>;
     subscribePrivate(peerAddr: string, topic: string, connectCallback: () => void, messageCallback: (data: any) => void): Promise<void>;
-    getOrCreateContact(peerId: string, addressType: string, addressValue: string): Promise<ContactItem>;
+    getOrCreateContact(peerId: string, addressType: string, addressValue: string, contactBook?: ContactBook): Promise<ContactItem>;
     createContact(peerId: string, addressType?: string, addressValue?: string): Promise<ContactItem>;
     getAllContacts(peerId: string): Promise<ContactItem[]>;
     getContactBook(peerId: string): Promise<ContactBook>;

+ 5 - 2
lib/index.js

@@ -234,9 +234,12 @@ class BankClient {
             yield this.connectWebsocket(peerAddr, topic, connectCallback, messageCallback);
         });
     }
-    getOrCreateContact(peerId, addressType, addressValue) {
+    getOrCreateContact(peerId, addressType, addressValue, contactBook) {
         return __awaiter(this, void 0, void 0, function* () {
-            const contactBook = yield this.getContactBook(peerId);
+            if (contactBook == null) {
+                console.log('warning: inefficient');
+                contactBook = yield this.getContactBook(peerId);
+            }
             const existing = contactBook.lookupByAddress(addressType, addressValue);
             if (existing != null) {
                 return existing;

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
lib/index.js.map


+ 5 - 2
src/index.ts

@@ -228,8 +228,11 @@ export class BankClient {
       await this.connectWebsocket(peerAddr, topic, connectCallback, messageCallback);
     }
 
-    public async getOrCreateContact(peerId: string, addressType: string, addressValue: string): Promise<ContactItem> {
-      const contactBook = await this.getContactBook(peerId);
+    public async getOrCreateContact(peerId: string, addressType: string, addressValue: string, contactBook?: ContactBook): Promise<ContactItem> {
+      if (contactBook == null) {
+        console.log('warning: inefficient');
+        contactBook = await this.getContactBook(peerId);
+      }
       const existing = contactBook.lookupByAddress(addressType, addressValue);
       if (existing != null) {
         return existing;