Browse Source

put undefined checks to avoid errors in application

rohit.gowda 4 years ago
parent
commit
093841dc89
2 changed files with 6 additions and 3 deletions
  1. 1 1
      app/src/providers/crypto/crypto.ts
  2. 5 2
      app/src/providers/feed/feed.ts

+ 1 - 1
app/src/providers/crypto/crypto.ts

@@ -67,7 +67,7 @@ export class CryptoProvider {
     //get private key history from gun
     let link = await this.gun.getPvtKeyHistory(userId);
     // Fetch Private key history
-    if (link) {
+    if (link && link.key) {
       const encryptedKeyHistory = await this.ipfs.fetchJson(link.key);
       // Decrypt key history
       return JSON.parse(encryptedKeyHistory.toString());

+ 5 - 2
app/src/providers/feed/feed.ts

@@ -134,7 +134,10 @@ export class FeedProvider {
     for (let i = 0; i < resolvedPromises.length; i++) {
       if (resolvedPromises[i]) {
         let email = resolvedPromises[i]["email"];
-        this.opnpgp.lookupKeys(email);
+        
+        if(email){
+         this.opnpgp.lookupKeys(email);
+        }
       }
 
     }
@@ -180,7 +183,7 @@ export class FeedProvider {
             privateTweets.push(JSON.parse(decryptedTweet));
         }
       } catch (err) {
-        console.log("Error caught in feed");
+        console.log("Error caught in feed",err);
       }
 
       // let pvtKey = await this.storage.get("privateKey");