Browse Source

create login page and create dummy retweet

rohit.gowda 4 years ago
parent
commit
84a12f1a56

+ 13 - 6
app/src/components/tweet-actions/tweet-actions.ts

@@ -42,16 +42,16 @@ export class TweetActionsComponent {
   }
 
   get id() {
-    console.log('id');
     if (this.data["retweeted_status"]) {
       return this.data["retweeted_status"]["id_str"];
     } else {
+      console.log('id',this.data["id_str"]);
       return this.data["id_str"];
     }
   }
 
   private async getPrivateLikes(id: string) {
-    console.log('getPrivateLikes');
+    console.log('getPrivateLikes',id);
     const likeEntry = await this.gun.getLikes(this.id);
     if (likeEntry.likes > 0) {
       this.privateFavoriteCount = likeEntry.likes;
@@ -69,7 +69,7 @@ export class TweetActionsComponent {
   }
 
   toggleLike(id: string) {
-    console.log('toggleLike');
+    console.log('toggleLike: ',id);
     this.vibration.vibrate([100, 50, 100]);
     if (this.data["favorited"]) {
       this.removeLike(id);
@@ -95,7 +95,7 @@ export class TweetActionsComponent {
   }
 
   private removeLike(id: string): void {
-    console.log('removeLike:');
+    console.log('removeLike:',id);
     if(this.storage.get("mockup")){
        console.log('unlike tweet in mock');
         this.mockProv.unlikeTweet(id);
@@ -111,8 +111,15 @@ export class TweetActionsComponent {
   }
 
   retweetStatus(id: string): void {
-    console.log('retweetStatus');
-    this.navCtrl.push(WriteTweetPage, { tweetId: id });
+    if(this.storage.get("mockup")){
+        console.log('Retweeting status');
+         this.navCtrl.push(WriteTweetPage, { tweetId: id });
+    }
+    else{
+      console.log('retweetStatus');
+      this.navCtrl.push(WriteTweetPage, { tweetId: id });
+    }
+    
   }
 
   replyToStatus(id: string): void {

+ 4 - 0
app/src/components/tweet-body/tweet-body.ts

@@ -147,11 +147,14 @@ export class TweetBodyComponent {
   }
 
   private getUrlsForTweetArray(urls) {
+    console.log('url recovered are:',urls);
     const res = [];
     urls.forEach(element => {
+      console.log('element in geturl is:',element);
       const apiEntity = this.entities.urls.filter(
         el => el.url.toLowerCase() === element["url"].toLowerCase()
       )[0];
+      if(apiEntity)
       res.push({
         start: element.indices[0],
         stop: element.indices[1],
@@ -159,6 +162,7 @@ export class TweetBodyComponent {
         url: element["url"],
         text: apiEntity["display_url"] || element["url"]
       });
+    
     });
     return res;
   }

+ 1 - 0
app/src/components/tweet/tweet.ts

@@ -17,6 +17,7 @@ export class TweetComponent {
   constructor() {}
 
   get user() {
+    console.log('inside tweet.html tihs.data is:', this.data);
     if (this.data["retweeted_status"]) {
       return this.data["retweeted_status"]["user"];
     } else {

+ 11 - 2
app/src/pages/login/login.ts

@@ -7,8 +7,11 @@ import {
 } from "ionic-angular";
 import { AuthProvider } from "../../providers/auth/auth";
 import { AboutPage } from "../about/about";
+import { MockLoginPage } from "../mock-login/mock-login";
 // import { HomePage } from "../home/home";
 import { MockPage } from "../mock/mock";
+import { Storage } from "@ionic/storage";
+
 
 @IonicPage()
 @Component({
@@ -16,10 +19,14 @@ import { MockPage } from "../mock/mock";
   templateUrl: "login.html"
 })
 export class LoginPage {
+
+  mockUp: boolean;
+
   constructor(
     public navCtrl: NavController,
     private menuCtrl: MenuController,
-    private modalCtrl: ModalController
+    private modalCtrl: ModalController,
+    private storage: Storage
   ) {}
 
   ionViewDidLoad() {
@@ -27,7 +34,9 @@ export class LoginPage {
   }
 
   login() {
-   this.navCtrl.setRoot(MockPage);
+  this.mockUp = true;
+  this.storage.set("mockup", this.mockUp);
+   this.navCtrl.setRoot(MockLoginPage);
   }
 
   showAbout() {

+ 2 - 0
app/src/pages/mock-login/mock-login.ts

@@ -37,6 +37,8 @@ export class MockLoginPage implements OnInit {
         }
 
         else{
+            console.log('loginform control',this.loginForm);
+            if(this.loginForm.value['username'] == 'test' && this.loginForm.value['password'] == 'test' )
             this.navCtrl.setRoot(HomePage);
         }
     }

+ 0 - 3
app/src/pages/mock/mock.html

@@ -11,8 +11,5 @@
   <button ion-button outline block (click)="loginMock()">
     Mock Home
   </button>
-  <button ion-button outline block (click)="loginTwitter()">
-    Twitter Home
-  </button>
   </div>
 </ion-content>

+ 16 - 2
app/src/pages/write-tweet/write-tweet.ts

@@ -48,6 +48,7 @@ export class WriteTweetPage {
   ) {
     this.retweetId = this.navParams.get("tweetId");
     this.replyToStatusId = this.navParams.get("replyToStatus");
+    console.log('retweeting now? ',this.retweetId , this.replyToStatusId );
 
     this.tweet = this.formBuilder.group({
       text: [""],
@@ -86,11 +87,21 @@ export class WriteTweetPage {
   }
 
   async ionViewDidLoad() {
+    console.log('ceck if  the tweet is retweet or a reply',this.retweetId , this.replyToStatusId );
     if (this.retweetId) {
-      this.retweet = await this.twitter.fetchTweet(this.retweetId);
+      if( this.storage.get("mockup"))
+        console.log("retweeting in mockup");
+      else{
+        this.retweet = await this.twitter.fetchTweet(this.retweetId);
+        console.log('this.retweet is:',this.retweet );
+      }
     }
     if (this.replyToStatusId) {
+      if( this.storage.get("mockup"))
+        console.log("replying in mockup");
+      else
       this.replyTweet = await this.twitter.fetchTweet(this.replyToStatusId);
+    console.log('this.replyTweet is:',this.replyTweet );
     }
   }
 
@@ -130,7 +141,10 @@ export class WriteTweetPage {
     if (await this.storage.get("mockup")) {
       console.log('value of the tweet is:', this.tweet.value);
       console.log('publishing tweet for mock', this.tweet.value["text"]);
-      await this.mockProv.writeTweet(this.tweet.value["text"], this.tweet.value.p2p );
+      await this.mockProv.writeTweet(this.tweet.value["text"], 
+                                      this.tweet.value.p2p,
+                                       this.retweet,
+                                      this.replyToStatusId );
       // loading.dismiss();
     } else {
       console.log('in else ');

+ 32 - 3
app/src/providers/mock-provider/mock-provider.ts

@@ -59,14 +59,18 @@ export class MockProvider {
   }
 
   public async replyTweet() {}
-  public async countfav() {}
   
 
-  public writeTweet(twt: string , isPrivate: boolean) {
-    // console.log('inside writetweet',this.mockTweets[0]);
+  public writeTweet(twt: string , isPrivate: boolean, retwt, replyid) {
+    console.log('inside writetweet',retwt,replyid);
     // console.log('inside writetweet obj is:',this.mockTweets[0].full_text);
     let newTweet = Object.assign({}, this.mockTweets[0]);
+    newTweet.full_text = twt; 
+    newTweet.id = Math.floor(100000 + Math.random() * 900000); 
+    newTweet.id_str =  newTweet.id ;
     newTweet.full_text = twt;
+      newTweet.retweet = retwt;
+      newTweet.replyToStatusId = replyid;
     if(isPrivate){
       newTweet.private_tweet = true;
     }
@@ -108,6 +112,31 @@ export class MockProvider {
       });
   }
 
+  public likeTweet(id){
+    console.log('fetch tweet id:',id , this.mockTweets);
+    const result = this.mockTweets.find(x=>x.id_str == id);
+     // this.mockTweets.forEach(el=>{
+    //   console.log("mocktweet el is:",el);
+    // })
+    result.favorited = true;
+    result.favorite_count++;
+    console.log('tweet found and modified:',result);
+    return result;
+  }
+
+  public unlikeTweet(id){
+    console.log('fetch tweet id:',id , this.mockTweets);
+    const result = this.mockTweets.find(x=>x.id_str == id);
+     // this.mockTweets.forEach(el=>{
+    //   console.log("mocktweet el is:",el);
+    // })
+    result.favorited = false;
+    result.favorite_count--;
+    console.log('tweet found and modified:',result);
+    return result;
+  }
+
+
 
   private async fetchPrivateTweets(privateTweetsData: object[]) {
 

+ 173 - 5
app/src/providers/mock-provider/tweet.json

@@ -1,9 +1,9 @@
 [
 {
   "created_at": "Wed Sep 25 19:54:41 +0000 2019",
-  "id": 1176948153297362947,
-  "id_str": "1176948153297362947",
-  "full_text": "Fgttgf",
+  "id": 1176948153297362940,
+  "id_str": "1176948153297362940",
+  "full_text": "test tweet _hcd1",
   "truncated": false,
   "display_text_range": [
     0,
@@ -83,6 +83,174 @@
   "retweeted": false,
   "lang": "tl"
 },
+{
+  "created_at": "Wed Sep 29 19:54:41 +0000 2019",
+  "id": 1176948153297362987,
+  "id_str": "1176948153297362987",
+  "full_text": "Quoting test https://t.co/DVODmVC6SS",
+  "private_tweet": false,
+  "truncated": false,
+  "display_text_range": [
+    0,
+    13
+  ],
+  "entities":
+  {
+    "hashtags": [],
+    "symbols": [],
+    "user_mentions": [],
+    "urls": []
+  },
+  "source": "<a href=\"https://www.tk.informatik.tu-darmstadt.de/de/telecooperation-group/\" rel=\"nofollow\">Private Twitter (TU Darmstadt)</a>",
+  "in_reply_to_status_id": null,
+  "in_reply_to_status_id_str": null,
+  "in_reply_to_user_id": null,
+  "in_reply_to_user_id_str": null,
+  "in_reply_to_screen_name": null,
+  "geo": null,
+  "coordinates": null,
+  "place": null,
+  "contributors": null,
+  "is_quote_status": true,
+  "quoted_status": {
+   "created_at": "Wed Nov 06 10:21:58 +0000 2019",
+   "id": 1192024317871046700, 
+   "id_str": "1192024317871046656",
+   "full_text" : "Test", 
+   "truncated": false,
+   "entities":
+    {
+      "hashtags": [],
+      "symbols": [],
+      "user_mentions": [],
+      "urls": []
+    },
+    "favorite_count": 0,
+    "favorited": false,
+    "geo": null,
+    "in_reply_to_screen_name": null,
+    "in_reply_to_status_id": null,
+    "in_reply_to_status_id_str": null,
+    "in_reply_to_user_id": null,
+    "in_reply_to_user_id_str": null,
+    "is_quote_status": false,
+    "lang": "en",
+    "place": null,
+    "retweet_count": 0,
+    "retweeted": false,
+    "source": " <a href=\"https://www.tk.informatik.tu-darmstadt.de/de/telecooperation-group/\" rel=\"nofollow\">Private Twitter (TU Darmstadt)</a>",
+    "user":
+    {
+      "id": 1176099783947235318,
+      "id_str": "1176099783947235318",
+      "name": "Thesis test",
+      "screen_name": "test_thesis",
+      "location": "",
+      "description": "tweet://1192026901956583424 #hybridOSN",
+      "url": null,
+      "entities":
+      {
+        
+        "description":
+        {
+          "urls": []
+        }
+      },
+      "protected": false,
+      "followers_count": 0,
+      "friends_count": 0,
+      "listed_count": 0,
+      "created_at": "Mon Sep 23 11:43:41 +0000 2019",
+      "favourites_count": 0,
+      "utc_offset": null,
+      "time_zone": null,
+      "geo_enabled": false,
+      "verified": false,
+      "statuses_count": 2,
+      "lang": null,
+      "contributors_enabled": false,
+      "is_translator": false,
+      "is_translation_enabled": false,
+      "profile_background_color": "F5F8FA",
+      "profile_background_image_url": null,
+      "profile_background_image_url_https": null,
+      "profile_background_tile": false,
+      "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
+      "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
+      "profile_link_color": "1DA1F2",
+      "profile_sidebar_border_color": "C0DEED",
+      "profile_sidebar_fill_color": "DDEEF6",
+      "profile_text_color": "333333",
+      "profile_use_background_image": true,
+      "has_extended_profile": false,
+      "default_profile": true,
+      "default_profile_image": true,
+      "following": false,
+      "follow_request_sent": false,
+      "notifications": false,
+      "translator_type": "none"
+    },  
+    "truncated": false
+  },
+ "user":
+    {
+      "id": 1176099783947235318,
+      "id_str": "1176099783947235318",
+      "name": "Thesis test",
+      "screen_name": "test_thesis",
+      "location": "",
+      "description": "tweet://1192026901956583424 #hybridOSN",
+      "url": null,
+      "entities":
+      {
+        
+        "description":
+        {
+          "urls": []
+        }
+      },
+      "protected": false,
+      "followers_count": 0,
+      "friends_count": 0,
+      "listed_count": 0,
+      "created_at": "Mon Sep 23 11:43:41 +0000 2019",
+      "favourites_count": 0,
+      "utc_offset": null,
+      "time_zone": null,
+      "geo_enabled": false,
+      "verified": false,
+      "statuses_count": 2,
+      "lang": null,
+      "contributors_enabled": false,
+      "is_translator": false,
+      "is_translation_enabled": false,
+      "profile_background_color": "F5F8FA",
+      "profile_background_image_url": null,
+      "profile_background_image_url_https": null,
+      "profile_background_tile": false,
+      "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
+      "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
+      "profile_link_color": "1DA1F2",
+      "profile_sidebar_border_color": "C0DEED",
+      "profile_sidebar_fill_color": "DDEEF6",
+      "profile_text_color": "333333",
+      "profile_use_background_image": true,
+      "has_extended_profile": false,
+      "default_profile": true,
+      "default_profile_image": true,
+      "following": false,
+      "follow_request_sent": false,
+      "notifications": false,
+      "translator_type": "none"
+    },  
+  "quoted_status_id": 1192024317871046700,
+  "quoted_status_id_str": "1192024317871046656",
+  "retweet_count": 0,
+  "favorite_count": 0,
+  "favorited": false,
+  "retweeted": false,
+  "lang": "tl"
+},
 {
   "created_at": "Wed Sep 29 19:54:41 +0000 2019",
   "id": 1176948153297362947,
@@ -171,8 +339,8 @@
 },
 {
   "created_at": "Wed Sep 25 19:54:41 +0000 2019",
-  "id": 1176948153297362947,
-  "id_str": "1176948153297362947",
+  "id": 1176948153297362949,
+  "id_str": "1176948153297362949",
   "full_text": "Providing mock tweets",
   "truncated": false,
   "display_text_range": [