Browse Source

Issues specified cleared apk in src\app\apk\hybrid-osn-mockup

rohit.gowda 4 years ago
parent
commit
2383971b13
31 changed files with 22223 additions and 463 deletions
  1. BIN
      app/apk/hybrid-osn-mockup.apk
  2. 6 6
      app/src/app/app.component.ts
  3. 5 13
      app/src/app/app.module.ts
  4. 50 0
      app/src/app/user.json
  5. BIN
      app/src/assets/imgs/jd.png
  6. BIN
      app/src/assets/imgs/user2.png
  7. BIN
      app/src/assets/imgs/user3.png
  8. 21544 0
      app/src/assets/scripts/openpgp.js
  9. 145 0
      app/src/assets/scripts/openpgp.worker.js
  10. 1 1
      app/src/components/feed/feed.ts
  11. 2 4
      app/src/components/profile-header/profile-header.ts
  12. 5 36
      app/src/components/tweet-actions/tweet-actions.ts
  13. 76 76
      app/src/components/tweet-header/tweet-header.ts
  14. 1 0
      app/src/components/tweet/tweet.ts
  15. 18 36
      app/src/pages/home/home.ts
  16. 2 3
      app/src/pages/login/login.html
  17. 0 3
      app/src/pages/login/login.ts
  18. 8 6
      app/src/pages/mock-login/mock-login.html
  19. 3 0
      app/src/pages/mock-login/mock-login.scss
  20. 3 6
      app/src/pages/mock-login/mock-login.ts
  21. 7 8
      app/src/pages/profile/profile.ts
  22. 17 19
      app/src/pages/search-results-tweets-popular/search-results-tweets-popular.ts
  23. 14 16
      app/src/pages/search-results-tweets-recent/search-results-tweets-recent.ts
  24. 13 15
      app/src/pages/search-results-users/search-results-users.ts
  25. 28 65
      app/src/pages/write-tweet/write-tweet.ts
  26. 1 4
      app/src/providers/auth/auth.ts
  27. 9 8
      app/src/providers/crypto/crypto.ts
  28. 55 13
      app/src/providers/mock-provider/mock-provider.ts
  29. 84 0
      app/src/providers/mock-provider/sampleTweet.json
  30. 125 124
      app/src/providers/mock-provider/tweet.json
  31. 1 1
      app/src/providers/p2p-database-gun/p2p-database-gun.ts

BIN
apk-generated/app-debug.apk → app/apk/hybrid-osn-mockup.apk


+ 6 - 6
app/src/app/app.component.ts

@@ -3,15 +3,14 @@ import { Nav, Platform, Events } from "ionic-angular";
 import { StatusBar } from "@ionic-native/status-bar";
 import { SplashScreen } from "@ionic-native/splash-screen";
 import { Storage } from "@ionic/storage";
-
+import { LoginPage } from "../pages/login/login";
 import { AuthProvider } from "../providers/auth/auth";
 
 import { HomePage } from "../pages/home/home";
 import { SearchPage } from "../pages/search/search";
 import { SettingsPage } from "../pages/settings/settings";
-import { LoginPage } from "../pages/login/login";
 import { ProfilePage } from "../pages/profile/profile";
-import { TwitterApiProvider } from "../providers/twitter-api/twitter-api";
+import * as user from './user.json';
 
 @Component({
   templateUrl: "app.html"
@@ -29,7 +28,6 @@ export class MyApp {
     statusBar: StatusBar,
     splashScreen: SplashScreen,
     private authProvider: AuthProvider,
-    private twitter: TwitterApiProvider,
     private storage: Storage,
     private events: Events
   ) {
@@ -58,14 +56,16 @@ export class MyApp {
       this.rootPage = HomePage;
       await this.setUser();
     } else {
-      this.rootPage = LoginPage;
+       this.rootPage = LoginPage;;
     }
   }
 
   async setUser() {
     const userId = await this.storage.get("userId");
     console.log('settings the user as:',userId);
-    this.user = await this.twitter.fetchUser(userId);
+    this.user = user;
+    console.log("set user is:",this.user);
+    // this.user = await this.twitter.fetchUser(userId);
   }
 
   showProfile(userId) {

+ 5 - 13
app/src/app/app.module.ts

@@ -10,14 +10,11 @@ import { PhotoViewer } from "@ionic-native/photo-viewer";
 import { Vibration } from "@ionic-native/vibration";
 import { File } from "@ionic-native/file";
 import { AuthProvider } from "../providers/auth/auth";
-
+import { LoginPage } from "../pages/login/login";
 import { MyApp } from "./app.component";
 import { HomePage } from "../pages/home/home";
 import { SearchPage } from "../pages/search/search";
 import { SettingsPage } from "../pages/settings/settings";
-import { LoginPage } from "../pages/login/login";
-import { TwitterApiProvider } from "../providers/twitter-api/twitter-api";
-import { MockPage } from "../pages/mock/mock";
 import { MockLoginPage } from "../pages/mock-login/mock-login";
 import { FeedComponent } from "../components/feed/feed";
 import { TweetComponent } from "../components/tweet/tweet";
@@ -25,14 +22,13 @@ import { TweetHeaderComponent } from "../components/tweet-header/tweet-header";
 import { TweetBodyComponent } from "../components/tweet-body/tweet-body";
 import { TweetActionsComponent } from "../components/tweet-actions/tweet-actions";
 import { ProfilePage } from "../pages/profile/profile";
+import { P2pStorageIpfsProvider } from "../providers/p2p-storage-ipfs/p2p-storage-ipfs";
 import { ProfileHeaderComponent } from "../components/profile-header/profile-header";
 import { PipesModule } from "../pipes/pipes.module";
 import { WriteTweetPage } from "../pages/write-tweet/write-tweet";
 import { QuotedStatusComponent } from "../components/quoted-status/quoted-status";
-import { P2pStorageIpfsProvider } from "../providers/p2p-storage-ipfs/p2p-storage-ipfs";
-import { P2pDatabaseGunProvider } from "../providers/p2p-database-gun/p2p-database-gun";
-import { FeedProvider } from "../providers/feed/feed";
 import { MockProvider } from "../providers/mock-provider/mock-provider";
+import { P2pDatabaseGunProvider } from "../providers/p2p-database-gun/p2p-database-gun";
 import { MentionComponent } from "../components/mention/mention";
 import { HashtagComponent } from "../components/hashtag/hashtag";
 import { SearchResultsUsersPage } from "../pages/search-results-users/search-results-users";
@@ -47,9 +43,8 @@ import { CryptoProvider } from "../providers/crypto/crypto";
     MyApp,
     HomePage,
     SearchPage,
-    SettingsPage,
     LoginPage,
-    MockPage,
+    SettingsPage,
     MockLoginPage,
     ProfilePage,
     WriteTweetPage,
@@ -82,7 +77,6 @@ import { CryptoProvider } from "../providers/crypto/crypto";
     SearchPage,
     SettingsPage,
     LoginPage,
-    MockPage,
     MockLoginPage,
     ProfilePage,
     WriteTweetPage,
@@ -100,10 +94,8 @@ import { CryptoProvider } from "../providers/crypto/crypto";
     PhotoViewer,
     { provide: ErrorHandler, useClass: IonicErrorHandler },
     AuthProvider,
-    TwitterApiProvider,
-    P2pStorageIpfsProvider,
     P2pDatabaseGunProvider,
-    FeedProvider,
+    P2pStorageIpfsProvider,
     MockProvider,
     CryptoProvider,
     Vibration,

+ 50 - 0
app/src/app/user.json

@@ -0,0 +1,50 @@
+
+  {
+    "id": 1176099783947235328,
+    "id_str": "1176099783947235328",
+    "name": "Thesis test",
+    "screen_name": "test_thesis",
+    "location": "",
+    "description": "",
+    "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": "../../assets/imgs/jd.png",
+    "profile_image_url_https": "../../assets/imgs/jd.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"
+  }

BIN
app/src/assets/imgs/jd.png


BIN
app/src/assets/imgs/user2.png


BIN
app/src/assets/imgs/user3.png


File diff suppressed because it is too large
+ 21544 - 0
app/src/assets/scripts/openpgp.js


+ 145 - 0
app/src/assets/scripts/openpgp.worker.js

@@ -0,0 +1,145 @@
+(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
+// GPG4Browsers - An OpenPGP implementation in javascript
+// Copyright (C) 2011 Recurity Labs GmbH
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3.0 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+/* eslint-disable no-restricted-globals */
+/* eslint-disable no-var */
+/* eslint-disable vars-on-top */
+
+/**
+ * @fileoverview Provides functions for communicating with workers
+ * @see module:openpgp.initWorker
+ * @see module:openpgp.getWorker
+ * @see module:openpgp.destroyWorker
+ * @see module:worker/async_proxy
+ * @module worker/worker
+ */
+
+self.window = self; // to make UMD bundles work
+
+importScripts('openpgp.js');
+var openpgp = window.openpgp;
+
+var randomQueue = [];
+var MAX_SIZE_RANDOM_BUFFER = 60000;
+
+/**
+ * Handle random buffer exhaustion by requesting more random bytes from the main window
+ * @returns {Promise<Object>}  Empty promise whose resolution indicates that the buffer has been refilled
+ */
+function randomCallback() {
+
+  if (!randomQueue.length) {
+    self.postMessage({ event: 'request-seed', amount: MAX_SIZE_RANDOM_BUFFER });
+  }
+
+  return new Promise(function(resolve) {
+    randomQueue.push(resolve);
+  });
+}
+
+openpgp.crypto.random.randomBuffer.init(MAX_SIZE_RANDOM_BUFFER, randomCallback);
+
+/**
+ * Handle messages from the main window.
+ * @param  {Object} event   Contains event type and data
+ */
+self.onmessage = function(event) {
+  var msg = event.data || {};
+
+  switch (msg.event) {
+    case 'configure':
+      configure(msg.config);
+      break;
+
+    case 'seed-random':
+      seedRandom(msg.buf);
+
+      var queueCopy = randomQueue;
+      randomQueue = [];
+      for (var i = 0; i < queueCopy.length; i++) {
+        queueCopy[i]();
+      }
+
+      break;
+
+    default:
+      delegate(msg.id, msg.event, msg.options || {});
+  }
+};
+
+/**
+ * Set config from main context to worker context.
+ * @param  {Object} config   The openpgp configuration
+ */
+function configure(config) {
+  Object.keys(config).forEach(function(key) {
+    openpgp.config[key] = config[key];
+  });
+}
+
+/**
+ * Seed the library with entropy gathered window.crypto.getRandomValues
+ * as this api is only avalible in the main window.
+ * @param  {ArrayBuffer} buffer   Some random bytes
+ */
+function seedRandom(buffer) {
+  if (!(buffer instanceof Uint8Array)) {
+    buffer = new Uint8Array(buffer);
+  }
+  openpgp.crypto.random.randomBuffer.set(buffer);
+}
+
+/**
+ * Generic proxy function that handles all commands from the public api.
+ * @param  {String} method    The public api function to be delegated to the worker thread
+ * @param  {Object} options   The api function's options
+ */
+function delegate(id, method, options) {
+  if (typeof openpgp[method] !== 'function') {
+    response({ id:id, event:'method-return', err:'Unknown Worker Event' });
+    return;
+  }
+  // construct ReadableStreams from MessagePorts
+  openpgp.util.restoreStreams(options);
+  // parse cloned packets
+  options = openpgp.packet.clone.parseClonedPackets(options, method);
+  openpgp[method](options).then(function(data) {
+    // clone packets (for web worker structured cloning algorithm)
+    response({ id:id, event:'method-return', data:openpgp.packet.clone.clonePackets(data) });
+  }).catch(function(e) {
+    openpgp.util.print_debug_error(e);
+    response({
+      id:id, event:'method-return', err:e.message, stack:e.stack
+    });
+  });
+}
+
+/**
+ * Respond to the main window.
+ * @param  {Object} event  Contains event type and data
+ */
+function response(event) {
+  self.postMessage(event, openpgp.util.getTransferables(event.data, true));
+}
+
+/**
+ * Let the main window know the worker has loaded.
+ */
+postMessage({ event: 'loaded' });
+
+},{}]},{},[1]);

+ 1 - 1
app/src/components/feed/feed.ts

@@ -18,7 +18,7 @@ export class FeedComponent {
   @Input()
   enableRefresh: boolean = true;
   @Input()
-  enableInfiniteScroll: boolean = true;
+  enableInfiniteScroll: boolean = false;
   @Output()
   onRefresh: EventEmitter<any> = new EventEmitter<any>();
   @Output()

+ 2 - 4
app/src/components/profile-header/profile-header.ts

@@ -1,5 +1,4 @@
 import { Component, Input } from "@angular/core";
-import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
 import { PhotoViewer } from "@ionic-native/photo-viewer";
 
 @Component({
@@ -11,7 +10,6 @@ export class ProfileHeaderComponent {
   user: any;
 
   constructor(
-    private twitter: TwitterApiProvider,
     private photoViewer: PhotoViewer
   ) {}
 
@@ -24,12 +22,12 @@ export class ProfileHeaderComponent {
   }
 
   async follow(userId) {
-    await this.twitter.createFriendship(userId);
+    // await this.twitter.createFriendship(userId);
     this.user.following = true;
   }
 
   async unfollow(userId) {
-    await this.twitter.destroyFriendship(userId);
+    // await this.twitter.destroyFriendship(userId);
     this.user.following = false;
   }
 

+ 5 - 36
app/src/components/tweet-actions/tweet-actions.ts

@@ -1,5 +1,4 @@
 import { Component, Input, ChangeDetectorRef } from "@angular/core";
-import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
 import { NavController } from "ionic-angular";
 import { WriteTweetPage } from "../../pages/write-tweet/write-tweet";
 import { P2pDatabaseGunProvider } from "../../providers/p2p-database-gun/p2p-database-gun";
@@ -18,13 +17,12 @@ export class TweetActionsComponent {
   privateFavoriteCount: number = 0;
 
   constructor(
-    private twitter: TwitterApiProvider,
     private storage: Storage,
     private ref: ChangeDetectorRef,
     private navCtrl: NavController,
     private gun: P2pDatabaseGunProvider,
     private vibration: Vibration,
-     private mockProv: MockProvider
+    private mockProv: MockProvider
   ) {}
 
   ngOnInit() {
@@ -79,46 +77,17 @@ export class TweetActionsComponent {
 
   private like(id: string): void {
     console.log('like : ', id);
-    if(this.storage.get("mockup")){
-       console.log('like tweet in mock');
-       this.mockProv.likeTweet(id);
-    }
-    else{
-      this.twitter.likeTweet(id).then(() => {
-      this.data["favorited"] = true;
-      this.data["favorite_count"]++;
-      this.ref.detectChanges();
-      });
-    }
-    
+    this.mockProv.likeTweet(id);
   }
 
   private removeLike(id: string): void {
     console.log('removeLike:',id);
-    if(this.storage.get("mockup")){
-       console.log('unlike tweet in mock');
-        this.mockProv.unlikeTweet(id);
-    }
-    else{
-      this.twitter.unlikeTweet(id).then(() => {
-      this.data["favorited"] = false;
-      this.data["favorite_count"]--;
-      this.ref.detectChanges();
-      });
-    }
-    
+    this.mockProv.unlikeTweet(id);
   }
 
   retweetStatus(id: string): void {
-    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 });
-    }
-    
+    console.log('Retweeting status');
+    this.navCtrl.push(WriteTweetPage, { tweetId: id });
   }
 
   replyToStatus(id: string): void {

+ 76 - 76
app/src/components/tweet-header/tweet-header.ts

@@ -1,7 +1,6 @@
 import { Component, Input } from "@angular/core";
 import { ActionSheetController, App } from "ionic-angular";
 import { ProfilePage } from "../../pages/profile/profile";
-import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
 
 @Component({
   selector: "tweet-header",
@@ -15,93 +14,94 @@ export class TweetHeaderComponent {
 
   constructor(
     private appCtrl: App,
-    public actionSheetCtrl: ActionSheetController,
-    private twitter: TwitterApiProvider
-  ) {}
+    public actionSheetCtrl: ActionSheetController
+  ) {
+    console.log("user is:",this.user);
+  }
 
   showProfile(userId) {
     this.appCtrl.getRootNav().push(ProfilePage, { userId });
   }
 
   showActions(userId) {
-    this.twitter.fetchUser(userId).then(user => {
-      this.actionSheetCtrl
-        .create({
-          title: "@" + this.user["screen_name"],
-          buttons: this.getButtonsForActionSheet(user)
-        })
-        .present();
-    });
+    // this.twitter.fetchUser(userId).then(user => {
+    //   this.actionSheetCtrl
+    //     .create({
+    //       title: "@" + this.user["screen_name"],
+    //       buttons: this.getButtonsForActionSheet(user)
+    //     })
+    //     .present();
+    // });
   }
 
   private getButtonsForActionSheet(user) {
-    const buttons = [];
-    if (user.following) {
-      // Unfollow
-      buttons.push({
-        text: "Unfollow",
-        role: "destructive",
-        handler: () => {
-          this.twitter.destroyFriendship(user.id_str);
-        }
-      });
-    } else {
-      // Follow
-      buttons.push({
-        text: "Follow",
-        role: "destructive",
-        handler: () => {
-          this.twitter.createFriendship(user.id_str);
-        }
-      });
-    }
+  //   const buttons = [];
+  //   if (user.following) {
+  //     // Unfollow
+  //     buttons.push({
+  //       text: "Unfollow",
+  //       role: "destructive",
+  //       handler: () => {
+  //         this.twitter.destroyFriendship(user.id_str);
+  //       }
+  //     });
+  //   } else {
+  //     // Follow
+  //     buttons.push({
+  //       text: "Follow",
+  //       role: "destructive",
+  //       handler: () => {
+  //         this.twitter.createFriendship(user.id_str);
+  //       }
+  //     });
+  //   }
 
-    if (user.muting) {
-      // unmute
-      buttons.push({
-        text: "Unmute",
-        role: "destructive",
-        handler: () => {
-          this.twitter.unmuteUser(user.id_str);
-        }
-      });
-    } else {
-      // mute
-      buttons.push({
-        text: "Mute",
-        role: "destructive",
-        handler: () => {
-          this.twitter.muteUser(user.id_str);
-        }
-      });
-    }
+  //   if (user.muting) {
+  //     // unmute
+  //     buttons.push({
+  //       text: "Unmute",
+  //       role: "destructive",
+  //       handler: () => {
+  //         this.twitter.unmuteUser(user.id_str);
+  //       }
+  //     });
+  //   } else {
+  //     // mute
+  //     buttons.push({
+  //       text: "Mute",
+  //       role: "destructive",
+  //       handler: () => {
+  //         this.twitter.muteUser(user.id_str);
+  //       }
+  //     });
+  //   }
 
-    if (user.blocking) {
-      // Unblock
-      buttons.push({
-        text: "Unblock",
-        role: "destructive",
-        handler: () => {
-          this.twitter.unblockUser(user.id_str);
-        }
-      });
-    } else {
-      // Block
-      buttons.push({
-        text: "Block",
-        role: "destructive",
-        handler: () => {
-          this.twitter.blockUser(user.id_str);
-        }
-      });
-    }
+  //   if (user.blocking) {
+  //     // Unblock
+  //     buttons.push({
+  //       text: "Unblock",
+  //       role: "destructive",
+  //       handler: () => {
+  //         this.twitter.unblockUser(user.id_str);
+  //       }
+  //     });
+  //   } else {
+  //     // Block
+  //     buttons.push({
+  //       text: "Block",
+  //       role: "destructive",
+  //       handler: () => {
+  //         this.twitter.blockUser(user.id_str);
+  //       }
+  //     });
+  //   }
 
-    // Cancel button
-    buttons.push({
-      text: "Cancel",
-      role: "cancel"
-    });
+  //   // Cancel button
+  //   buttons.push({
+  //     text: "Cancel",
+  //     role: "cancel"
+  //   });
 
-    return buttons;
+  //   return buttons;
   }
 }

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

@@ -17,6 +17,7 @@ export class TweetComponent {
   constructor() {}
 
   get user() {
+    console.log("gettings user",this.data);
     if (this.data["retweeted_status"]) {
       return this.data["retweeted_status"]["user"];
     } else {

+ 18 - 36
app/src/pages/home/home.ts

@@ -9,7 +9,6 @@ import {
 } from "ionic-angular";
 import { Storage } from "@ionic/storage";
 import { WriteTweetPage } from "../write-tweet/write-tweet";
-import { FeedProvider } from "../../providers/feed/feed";
 import { MockProvider } from "../../providers/mock-provider/mock-provider";
 
 @IonicPage()
@@ -25,11 +24,11 @@ export class HomePage {
   constructor(
     public navCtrl: NavController,
     private menuCtrl: MenuController,
-    private feed: FeedProvider,
     private mockProv: MockProvider,
     private storage: Storage,
     private loadingCtrl: LoadingController
-  ) {}
+  ) {
+  }
 
   ionViewDidLoad() {
     this.menuCtrl.enable(true, "sideNav");
@@ -38,56 +37,39 @@ export class HomePage {
   async ionViewDidEnter() {
     const loading = this.loadingCtrl.create();
     loading.present();
-    this.mock = await this.storage.get("mockup");
-    console.log('mockup?', this.mock);
+    await this.loadTimeline();
+    loading.dismiss();
+  }
 
-    if (this.mock) {
-      this.mockProv
+  async loadTimeline(){
+     this.mockProv
         .loadHomeTimeline()
         .then(tweets => {
+          this.tweets=[];
+          Object.assign(this.tweets, tweets);
           console.log("HOME tweets are: ", tweets);
-          this.tweets = tweets;
-          loading.dismiss();
+          // this.tweets = tweets;
         })
         .catch(err => console.error('error in timeline', err));
-      // console.log('tweets from htl are:',this.tweets);
-
-    } else {
-      console.log('entered ionic view');
-      this.feed
-        .loadHomeTimeline()
-        .then(tweets => {
-          this.tweets = tweets;
-          loading.dismiss();
-        })
-        .catch(err => console.error(err));
-
-    }
-    // loading.dismiss();
   }
 
   doRefresh(refresher: Refresher) {
-    if (this.mock) {
       console.log('mock refresher called',refresher);
       this.mockProv.loadHomeTimeline().then(tweets => {
         this.tweets = tweets;
         refresher.complete();
       });
-    } else {
-      this.feed.loadHomeTimeline().then(tweets => {
-        this.tweets = tweets;
-        refresher.complete();
-      });
-    }
   }
 
   loadMore(infiniteScroll: InfiniteScroll) {
-    this.feed
-      .loadHomeTimeline(this.oldestPublicTweet, this.oldestPrivateTweet)
-      .then(tweets => {
-        this.tweets = this.tweets.concat(tweets);
-        infiniteScroll.complete();
-      });
+    
+    // this.mockProv
+    //   .loadHomeTimeline(this.oldestPublicTweet, this.oldestPrivateTweet)
+    //   .then(tweets => {
+    //     this.tweets = this.tweets.concat(tweets);
+    //     infiniteScroll.complete();
+    //   });
+     infiniteScroll.complete();
   }
 
   writeTweet() {

+ 2 - 3
app/src/pages/login/login.html

@@ -7,9 +7,8 @@
   </div>
   <div class="content">
     <h1>HOSN</h1>
-    <small><b>Twitter (as you know it) with additional means of PRIVACY control</b></small>
-<small> HOSN allows you to whisper privately to your fellows beyond the knowledge of</small>
-                     <small>Twitter or any third party</small>
+    <small><b>Twitter (as you know it) with additional means of PRIVACY control</b> HOSN allows you to whisper privately to your fellows beyond the knowledge of</small>
+     <small>Twitter or any third party</small>
     <button ion-button outline block (click)="login()">Login</button>
     <a href="#" (click)="showAbout()">Learn more</a>
   </div>

+ 0 - 3
app/src/pages/login/login.ts

@@ -5,11 +5,8 @@ import {
   MenuController,
   ModalController
 } 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";
 
 

+ 8 - 6
app/src/pages/mock-login/mock-login.html

@@ -25,16 +25,19 @@
 
 <form [formGroup]="loginForm" class="login" (ngSubmit)="onSubmit()">
     <div class="form-group">
-        <input type="text" formControlName="username" placeholder="Nutzername oder E-mail" class="form-control username1" [ngClass]="{ 'is-invalid': submitted && f.username.errors }" />
-        <div *ngIf="submitted && f.username.errors" class="invalid-feedback">
-            <div *ngIf="f.username.errors.required">Username is required</div>
+      <div *ngIf="submitted && f.username.errors" class="invalid-feedback">
+            <div *ngIf="f.username.errors.required">Username is required
+            </div>
         </div>
+        <input type="text" formControlName="username" placeholder="Nutzername oder E-mail" class="form-control username1" [ngClass]="{ 'is-invalid': submitted && f.username.errors }" />
+
     </div>
     <div class="form-group">
-        <input type="password" formControlName="password" placeholder="Passwort"  class="form-control password1" [ngClass]="{ 'is-invalid': submitted && f.password.errors }" />
-        <div *ngIf="submitted && f.password.errors" class="invalid-feedback">
+      <div *ngIf="submitted && f.password.errors" class="invalid-feedback">
             <div *ngIf="f.password.errors.required">Password is required</div>
         </div>
+        <input type="password" formControlName="password" placeholder="Passwort"  class="form-control password1" [ngClass]="{ 'is-invalid': submitted && f.password.errors }" />
+        
     </div>
 
     <div>
@@ -43,7 +46,6 @@
 
     <div class="form-group">
         <button [disabled]="loading" class="btn btn-primary login-btn">Log In</button>
-        <!-- <img *ngIf="loading" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" /> -->
         <button [disabled]="loading" class="btn btn-primary close-btn">Cancel</button>       
     </div>
 </form>

+ 3 - 0
app/src/pages/mock-login/mock-login.scss

@@ -45,6 +45,9 @@ mock-login{
 	}
 	.forgot_pass{
 
+	}
+	.invalid-feedback{
+	color:red;
 	}
 
 	.username1{

+ 3 - 6
app/src/pages/mock-login/mock-login.ts

@@ -4,12 +4,9 @@ import { first } from 'rxjs/operators';
 import {NavController} from "ionic-angular";
 import { HomePage } from "../home/home";
 
-@IonicPage()
 @Component({
-    selector: "mock-login",
-    templateUrl: 'mock-login.html'
-})
-
+     selector: "mock-login",
+     templateUrl: 'mock-login.html'})
 export class MockLoginPage implements OnInit {
     loginForm: FormGroup;
     loading = false;
@@ -43,7 +40,7 @@ export class MockLoginPage implements OnInit {
 
         else{
             console.log('loginform control',this.loginForm);
-            if(this.loginForm.value['username'].toLowerCase() == 'test' && this.loginForm.value['password'].toLowerCase() == 'test' )
+            if(this.loginForm.value['username'] != '' && this.loginForm.value['password'] != '' )
             this.navCtrl.setRoot(HomePage);
         }
     }

+ 7 - 8
app/src/pages/profile/profile.ts

@@ -7,8 +7,8 @@ import {
   Content,
   LoadingController
 } from "ionic-angular";
-import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
-import { FeedProvider } from "../../providers/feed/feed";
+import { MockProvider } from "../../providers/mock-provider/mock-provider";
+
 
 @IonicPage()
 @Component({
@@ -29,8 +29,7 @@ export class ProfilePage {
     public navCtrl: NavController,
     private loadingCtrl: LoadingController,
     private navParams: NavParams,
-    private twitter: TwitterApiProvider,
-    private feed: FeedProvider
+    private mockProv: MockProvider
   ) {}
 
   ionViewDidLoad() {
@@ -42,10 +41,10 @@ export class ProfilePage {
     const userId = this.navParams.get("userId");
 
     // Fetch user details from Twitter
-    this.twitter.fetchUser(userId).then(res => (this.user = res));
+    // this.twitter.fetchUser(userId).then(res => (this.user = res));
 
     // Load user's timeline from Twitter and P2P
-    this.feed.loadUserTimeline(userId).then(res => {
+    this.mockProv.loadUserTimeline(userId).then(res => {
       if (res.length > 0) {
         // Store tweets
         this.tweets = res;
@@ -58,7 +57,7 @@ export class ProfilePage {
   }
 
   doRefresh(refresher) {
-    this.feed.loadUserTimeline(this.user.id_str).then(res => {
+    this.mockProv.loadUserTimeline(this.user.id_str).then(res => {
       if (res.length > 0) {
         // Replace tweets
         this.tweets = res;
@@ -71,7 +70,7 @@ export class ProfilePage {
 
   loadMore(infiniteScroll: InfiniteScroll) {
     if (this.enableInfiniteScroll) {
-      this.feed
+      this.mockProv
         .loadUserTimeline(
           this.user.id_str,
           this.oldestPublicTweet,

+ 17 - 19
app/src/pages/search-results-tweets-popular/search-results-tweets-popular.ts

@@ -7,7 +7,6 @@ import {
   InfiniteScroll,
   Events
 } from "ionic-angular";
-import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
 
 @IonicPage()
 @Component({
@@ -21,43 +20,42 @@ export class SearchResultsTweetsPopularPage {
   constructor(
     public navCtrl: NavController,
     public navParams: NavParams,
-    private twitter: TwitterApiProvider,
     private events: Events
   ) {
     this.query = this.navParams.data;
 
     this.events.subscribe("query:changed", query => {
       if (query.length) {
-        this.twitter
-          .searchPopularTweets(query)
-          .then(res => (this.tweets = res));
-        this.query = query;
+        // this.twitter
+        //   .searchPopularTweets(query)
+        //   .then(res => (this.tweets = res));
+        // this.query = query;
       }
     });
   }
 
   async ionViewDidLoad() {
     if (this.query.length) {
-      this.tweets = await this.twitter.searchPopularTweets(this.query);
+      // this.tweets = await this.twitter.searchPopularTweets(this.query);
     }
   }
 
   doRefresh(refresher: Refresher) {
-    this.twitter.searchPopularTweets(this.query).then(tweets => {
-      this.tweets = tweets;
-      refresher.complete();
-    });
+    // this.twitter.searchPopularTweets(this.query).then(tweets => {
+    //   this.tweets = tweets;
+    //   refresher.complete();
+    // });
   }
 
   loadMore(infiniteScroll: InfiniteScroll) {
-    this.twitter
-      .searchPopularTweets(this.query, this.oldestTweet)
-      .then(tweets => {
-        this.tweets["statuses"] = this.tweets["statuses"].concat(
-          tweets["statuses"]
-        );
-        infiniteScroll.complete();
-      });
+    // this.twitter
+    //   .searchPopularTweets(this.query, this.oldestTweet)
+    //   .then(tweets => {
+    //     this.tweets["statuses"] = this.tweets["statuses"].concat(
+    //       tweets["statuses"]
+    //     );
+    //     infiniteScroll.complete();
+    //   });
   }
 
   get oldestTweet() {

+ 14 - 16
app/src/pages/search-results-tweets-recent/search-results-tweets-recent.ts

@@ -7,7 +7,6 @@ import {
   InfiniteScroll,
   Events
 } from "ionic-angular";
-import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
 
 @IonicPage()
 @Component({
@@ -21,14 +20,13 @@ export class SearchResultsTweetsRecentPage {
   constructor(
     public navCtrl: NavController,
     public navParams: NavParams,
-    private twitter: TwitterApiProvider,
     private events: Events
   ) {
     this.query = this.navParams.data;
 
     this.events.subscribe("query:changed", query => {
       if (query.length) {
-        this.twitter.searchRecentTweets(query).then(res => (this.tweets = res));
+        // this.twitter.searchRecentTweets(query).then(res => (this.tweets = res));
         this.query = query;
       }
     });
@@ -36,26 +34,26 @@ export class SearchResultsTweetsRecentPage {
 
   async ionViewDidLoad() {
     if (this.query.length) {
-      this.tweets = await this.twitter.searchRecentTweets(this.query);
+      // this.tweets = await this.twitter.searchRecentTweets(this.query);
     }
   }
 
   doRefresh(refresher: Refresher) {
-    this.twitter.searchRecentTweets(this.query).then(tweets => {
-      this.tweets = tweets;
-      refresher.complete();
-    });
+    // this.twitter.searchRecentTweets(this.query).then(tweets => {
+    //   this.tweets = tweets;
+    //   refresher.complete();
+    // });
   }
 
   loadMore(infiniteScroll: InfiniteScroll) {
-    this.twitter
-      .searchRecentTweets(this.query, this.oldestTweet)
-      .then(tweets => {
-        this.tweets["statuses"] = this.tweets["statuses"].concat(
-          tweets["statuses"]
-        );
-        infiniteScroll.complete();
-      });
+    // this.twitter
+    //   .searchRecentTweets(this.query, this.oldestTweet)
+    //   .then(tweets => {
+    //     this.tweets["statuses"] = this.tweets["statuses"].concat(
+    //       tweets["statuses"]
+    //     );
+    //     infiniteScroll.complete();
+    //   });
   }
 
   get oldestTweet() {

+ 13 - 15
app/src/pages/search-results-users/search-results-users.ts

@@ -8,7 +8,6 @@ import {
   App,
   Events
 } from "ionic-angular";
-import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
 import { ProfilePage } from "../profile/profile";
 
 @IonicPage()
@@ -25,22 +24,21 @@ export class SearchResultsUsersPage {
     public navCtrl: NavController,
     public navParams: NavParams,
     private appCtrl: App,
-    private twitter: TwitterApiProvider,
     private events: Events
   ) {
     this.query = this.navParams.data;
 
     this.events.subscribe("query:changed", query => {
       if (query.length) {
-        this.twitter.searchUsers(query).then(res => (this.users = res));
-        this.query = query;
+        // this.twitter.searchUsers(query).then(res => (this.users = res));
+        // this.query = query;
       }
     });
   }
 
   async ionViewDidLoad() {
     if (this.query.length) {
-      this.users = await this.twitter.searchUsers(this.query);
+      // this.users = await this.twitter.searchUsers(this.query);
     }
   }
 
@@ -50,18 +48,18 @@ export class SearchResultsUsersPage {
   }
 
   doRefresh(refresher: Refresher) {
-    this.twitter.searchUsers(this.query).then(users => {
-      this.users = users;
-      this.nextPage = 2;
-      refresher.complete();
-    });
+    // this.twitter.searchUsers(this.query).then(users => {
+    //   this.users = users;
+    //   this.nextPage = 2;
+    //   refresher.complete();
+    // });
   }
 
   loadMore(infiniteScroll: InfiniteScroll) {
-    this.twitter.searchUsers(this.query, this.nextPage).then(users => {
-      this.users = this.users.concat(users);
-      infiniteScroll.complete();
-      this.nextPage = this.nextPage + 1;
-    });
+    // this.twitter.searchUsers(this.query, this.nextPage).then(users => {
+    //   this.users = this.users.concat(users);
+    //   infiniteScroll.complete();
+    //   this.nextPage = this.nextPage + 1;
+    // });
   }
 }

+ 28 - 65
app/src/pages/write-tweet/write-tweet.ts

@@ -14,12 +14,11 @@ import {
   AbstractControl
 } from "@angular/forms";
 import { MockProvider } from "../../providers/mock-provider/mock-provider";
-import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
 import { Storage } from "@ionic/storage";
-import { P2pStorageIpfsProvider } from "../../providers/p2p-storage-ipfs/p2p-storage-ipfs";
-import { P2pDatabaseGunProvider } from "../../providers/p2p-database-gun/p2p-database-gun";
 import twittertext from "twitter-text";
+import { P2pStorageIpfsProvider } from "../../providers/p2p-storage-ipfs/p2p-storage-ipfs";
 import { CryptoProvider } from "../../providers/crypto/crypto";
+import { P2pDatabaseGunProvider } from "../../providers/p2p-database-gun/p2p-database-gun";
 
 @IonicPage()
 @Component({
@@ -37,7 +36,6 @@ export class WriteTweetPage {
     public navCtrl: NavController,
     public navParams: NavParams,
     private formBuilder: FormBuilder,
-    private twitter: TwitterApiProvider,
     private loadingCtrl: LoadingController,
     private storage: Storage,
     private ipfs: P2pStorageIpfsProvider,
@@ -45,6 +43,7 @@ export class WriteTweetPage {
     private cryptoUtils: CryptoProvider,
     private alertCtrl: AlertController,
     private mockProv: MockProvider
+    
   ) {
     this.retweetId = this.navParams.get("tweetId");
     this.replyToStatusId = this.navParams.get("replyToStatus");
@@ -88,21 +87,12 @@ export class WriteTweetPage {
 
   async ionViewDidLoad() {
     if (this.retweetId) {
-      if (this.storage.get("mockup")) {
         this.retweet = this.mockProv.fetchTweet(this.retweetId);
         console.log("retweeted tweet", this.retweet);
-      } else {
-        this.retweet = await this.twitter.fetchTweet(this.retweetId);
-      }
     }
     if (this.replyToStatusId) {
-      if (this.storage.get("mockup")){
         console.log("replying in mockup");
         this.replyTweet = await this.mockProv.fetchTweet(this.replyToStatusId);
-      }
-      else
-        this.replyTweet = await this.twitter.fetchTweet(this.replyToStatusId);
-      console.log('this.replyTweet is:', this.replyTweet);
     }
   }
 
@@ -137,40 +127,13 @@ export class WriteTweetPage {
   async submitTweet() {
     const loading = this.loadingCtrl.create();
     loading.present();
-    if (await this.storage.get("mockup")) {
       console.log('value of the tweet is:', this.tweet.value);
       await this.mockProv.writeTweet(this.tweet.value["text"],
         this.tweet.value.p2p,
         this.retweet,
         this.replyTweet);
-    } else {
-      if (this.tweet.value.p2p) {
-        loading.setContent("Validate keys...");
-        if (
-          (await this.cryptoUtils.isPrivateKeySet()) &&
-          (await this.cryptoUtils.isPublicKeyPublished())
-        ) {
-          loading.setContent("Publish private tweet...");
-          await this.tweetPrivate();
-        } else {
-          loading.dismiss();
-          const alert = this.alertCtrl.create({
-            title: "Oooops...",
-            message: "Please verify that you have set a private and public key in the settings and that your latest public key was published."
-          });
-          alert.present();
-          return;
-        }
-      } else {
-        loading.setContent("Publish on Twitter...");
-        await this.twitter.tweet(
-          this.tweet.value["text"],
-          this.retweet,
-          this.replyToStatusId
-        );
-      }
-    }
     loading.dismiss();
+    console.log("POP NAVCTRL")
     this.navCtrl.pop();
   }
 
@@ -219,29 +182,29 @@ export class WriteTweetPage {
 
   private async getMentions(status: string) {
     // extract mentions
-    const entities = twittertext.extractMentionsWithIndices(status);
-
-    // add user_id
-    const entitiesWithPromises = entities.map(async mention => {
-      try {
-        const user = await this.twitter.fetchUserFromScreenName(
-          mention.screenName
-        );
-        mention["id_str"] = user[0]["id_str"];
-        mention["screen_name"] = mention.screenName;
-        delete mention.screenName;
-      } catch (err) {
-        console.error(
-          "There is no user signed up to twitter with username: " +
-          mention.screenName
-        );
-      }
-      return mention;
-    });
-
-    // filter for valid users and return
-    return (await Promise.all(entitiesWithPromises)).filter(el =>
-      el.hasOwnProperty("id_str")
-    );
+    // const entities = twittertext.extractMentionsWithIndices(status);
+
+    // // add user_id
+    // const entitiesWithPromises = entities.map(async mention => {
+    //   try {
+    //     const user = await this.twitter.fetchUserFromScreenName(
+    //       mention.screenName
+    //     );
+    //     mention["id_str"] = user[0]["id_str"];
+    //     mention["screen_name"] = mention.screenName;
+    //     delete mention.screenName;
+    //   } catch (err) {
+    //     console.error(
+    //       "There is no user signed up to twitter with username: " +
+    //       mention.screenName
+    //     );
+    //   }
+    //   return mention;
+    // });
+
+    // // filter for valid users and return
+    // return (await Promise.all(entitiesWithPromises)).filter(el =>
+    //   el.hasOwnProperty("id_str")
+    // );
   }
 }

+ 1 - 4
app/src/providers/auth/auth.ts

@@ -2,7 +2,6 @@ import { HttpClient } from "@angular/common/http";
 import { Injectable } from "@angular/core";
 import { Storage } from "@ionic/storage";
 import firebase from "firebase";
-import { TwitterApiProvider } from "../twitter-api/twitter-api";
 
 @Injectable()
 export class AuthProvider {
@@ -11,7 +10,6 @@ export class AuthProvider {
   constructor(
     public http: HttpClient,
     private storage: Storage,
-    private twitter: TwitterApiProvider
   ) {
     const config = {
       apiKey: "AIzaSyCMYjjtPPZak7wBBnh9sy8Yr3Fz1145MuM",
@@ -35,8 +33,7 @@ export class AuthProvider {
       .auth()
       .signInWithRedirect(this.authProvider)
       .then(() => firebase.auth().getRedirectResult())
-      .then(this.setKeys)
-      .then(() => this.twitter.initApi());
+      .then(this.setKeys);
   }
 
   /**

+ 9 - 8
app/src/providers/crypto/crypto.ts

@@ -1,7 +1,8 @@
 import { Injectable } from "@angular/core";
-import { TwitterApiProvider } from "../twitter-api/twitter-api";
 import { P2pStorageIpfsProvider } from "../p2p-storage-ipfs/p2p-storage-ipfs";
 import { Storage } from "@ionic/storage";
+import { MockProvider } from "../../providers/mock-provider/mock-provider";
+
 import NodeRSA from "node-rsa";
 declare var TextDecoder: any;
 declare var TextEncoder: any;
@@ -12,9 +13,9 @@ export class CryptoProvider {
   HYBRID_OSN_AES_KEY = "Z1vxAULQnZdoWhJOvv+hWEvVpyUHzNjD/ichEE2c8i4=";
 
   constructor(
-    private twitter: TwitterApiProvider,
     private ipfs: P2pStorageIpfsProvider,
-    private storage: Storage
+    private storage: Storage,
+    private mockProv: MockProvider
   ) {
     this.init();
   }
@@ -55,19 +56,19 @@ export class CryptoProvider {
     const res = await this.ipfs.storePublicKey(encryptedPublicKeyHistory);
 
     // tweet ipfs link
-    const tweetResponse = await this.twitter.tweet(
-      "ipfs://" + res["Hash"] + " #hybridOSN"
+    const tweetResponse = await this.mockProv.writeTweet(
+      "ipfs://" + res["Hash"] + " #hybridOSN" , true
     );
 
     // ... and update description in user profile with tweet id
-    this.twitter.updateProfileDescription(
+    this.mockProv.updateProfileDescription(
       "tweet://" + tweetResponse["data"]["id_str"] + " #hybridOSN"
     );
   }
 
   private async getKeyHistory(userId: string) {
     // Get user description
-    const userData = await this.twitter.fetchUser(userId);
+    const userData = await this.mockProv.fetchUser(userId);
     const profileDescription = userData["description"];
 
     // Get tweet with link to key history
@@ -75,7 +76,7 @@ export class CryptoProvider {
     if (tweetId.length === 0) {
       return null;
     }
-    const tweetWithKeyHistoryLink = await this.twitter.fetchTweet(tweetId);
+    const tweetWithKeyHistoryLink = await this.mockProv.fetchTweet(tweetId);
 
     // Extract link to public key
     const link = this.extractLinkFromDescription(

+ 55 - 13
app/src/providers/mock-provider/mock-provider.ts

@@ -1,9 +1,11 @@
 import { Injectable } from "@angular/core";
 import { Storage } from "@ionic/storage";
-import { Platform } from 'ionic-angular';
+import { Platform,Events } from 'ionic-angular';
 import { File } from '@ionic-native/file';
 import { HttpClient } from "@angular/common/http";
 import * as tweets from './tweet.json';
+import * as user from '../../app/user.json';
+import * as sampleTweet from './sampleTweet.json';
 declare var cordova: any;
 
 @Injectable()
@@ -11,6 +13,7 @@ export class MockProvider {
   friends;
   userId: string;
   mockTweets;
+  sampleTweet;
   result;
   fileRead: Boolean;
 
@@ -18,10 +21,13 @@ export class MockProvider {
     private storage: Storage,
     private file: File,
     public http: HttpClient,
-    private platform: Platform
+    private platform: Platform,
+    private events: Events
   ) {
     console.log('tweets are:', tweets);
     this.fileRead = false;
+    this.sampleTweet = sampleTweet;
+    console.log("sample tweet is;",this.sampleTweet);
     this.mockTweets = [...tweets];
     console.log(' this.mockTweets are:', this.mockTweets);
 
@@ -41,6 +47,13 @@ export class MockProvider {
     oldestPrivateTweet ?
   ) {
 
+  console.log('user time line called in mockprovider');
+    await this.readFile().then(tweets => {
+        console.log('new mocktweets after replace', this.mockTweets);
+    })
+    .catch(err => console.error('error in readfile', err));
+      return this.mockTweets
+        .sort((a, b) => this.sortByDateAsc(a, b));
   }
 
   /**
@@ -51,23 +64,28 @@ export class MockProvider {
    */
   public async loadHomeTimeline(oldestPublicTweet ? , oldestPrivateTweet ? ) {
     console.log('hometime line called in mockprovider');
-    this.readFile().then(tweets => {
+    await this.readFile().then(tweets => {
         console.log('new mocktweets after replace', this.mockTweets);
       })
       .catch(err => console.error('error in readfile', err));
-    return this.mockTweets;
+      return await this.mockTweets
+        .sort((a, b) => this.sortByDateAsc(a, b));
   }
 
   public async replyTweet() {}
 
 
-  public writeTweet(twt: string, isPrivate: boolean, retwt, reply) {
+  public async writeTweet(twt: string, isPrivate: boolean, retwt ?, reply ?) {
     console.log('inside writetweet', retwt, reply);
-    let newTweet = Object.assign({}, this.mockTweets[0]);
+    let newTweet:any = Object.assign({}, this.sampleTweet);
+    console.log("new tweet is:",newTweet);
+    // let newTweet:any = {};
     newTweet.full_text = twt;
     newTweet.id = Math.floor(100000 + Math.random() * 900000);
     newTweet.id_str = newTweet.id;
     newTweet.full_text = twt;
+    newTweet.created_at = Date.now();
+     newTweet.is_quote_status = false;
     if(retwt){
       newTweet.is_quote_status = true;
       newTweet.quoted_status = retwt;
@@ -86,26 +104,27 @@ export class MockProvider {
     }
     console.log('new tweet ', newTweet);
     this.mockTweets.push(newTweet);
-    this.writefile(this.mockTweets);
+    // this.events.publish("tweets:changed", this.mockTweets);
+    await this.writefile(this.mockTweets);
   }
 
   public async writefile(mocktweet) {
     await this.platform.ready()
       .then(_ => console.log('Device ready.'));
     //check if file exists
-    this.result = this.file.writeFile(this.file.dataDirectory, 'twets.json', JSON.stringify(mocktweet), { replace: true, append: false });
+    this.result = await this.file.writeFile(this.file.dataDirectory, 'twets.json', JSON.stringify(mocktweet), { replace: true, append: false });
     console.log("writing the file:", this.result);
-    console.log('Reading the file:', this.readFile());
   }
 
   public async readFile() {
     var readTweets: [];
     console.log('in readfile', this.mockTweets);
-    this.file.checkFile(this.file.dataDirectory, 'twets.json')
-      .then(() => {
+    console.log("this.file.dataDirectory:",this.file.dataDirectory);
+    await this.file.checkFile(this.file.dataDirectory, 'twets.json')
+      .then(async() => {
         console.log('file exists');
-        this.file.readAsText(this.file.dataDirectory, 'twets.json')
-          .then(data => {
+          await this.file.readAsText(this.file.dataDirectory, 'twets.json')
+          .then( data => {
             readTweets = JSON.parse(data);
             if (!this.fileRead) {
               // readTweets.forEach(el=>this.mockTweets.push(el));
@@ -120,6 +139,8 @@ export class MockProvider {
         console.error('File doesnt exist', err);
         this.file.writeFile(this.file.dataDirectory, 'twets.json', JSON.stringify(this.mockTweets), { replace: true });
       });
+
+      return this.mockTweets;
   }
 
   public likeTweet(id) {
@@ -151,9 +172,30 @@ export class MockProvider {
     return this.mockTweets.find(x => x.id_str == tweetID);
   }
 
+  public async fetchUser(userId) {
+    return user;
+  }
+
   private async fetchPrivateTweets(privateTweetsData: object[]) {
 
   }
 
+  public async updateProfileDescription(description: string) {
+    return user;
+  }
+
+  private sortByDateAsc(a, b) {
+    const dateA = new Date(a.created_at);
+    const dateB = new Date(b.created_at);
+
+    if (dateA > dateB) {
+      return -1;
+    } else if (dateA < dateB) {
+      return 1;
+    } else {
+      return 0;
+    }
+  }
+
 
 }

+ 84 - 0
app/src/providers/mock-provider/sampleTweet.json

@@ -0,0 +1,84 @@
+{
+  "created_at": "Wed Sep 25 19:54:41 +0000 2019",
+  "id": 1176948153297362965,
+  "id_str": "1176948153297362965",
+  "full_text": "Providing mock tweets",
+  "truncated": false,
+  "display_text_range": [
+    0,
+    6
+  ],
+  "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,
+  "user":
+  {
+    "id": 1176099783947235358,
+    "id_str": "1176099783947235358",
+    "name": "Thesis test",
+    "screen_name": "test_thesis",
+    "location": "",
+    "description": "",
+    "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": "../../assets/imgs/jd.png",
+    "profile_image_url_https": "../../assets/imgs/jd.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"
+  },
+  "geo": null,
+  "coordinates": null,
+  "place": null,
+  "contributors": null,
+  "is_quote_status": false,
+  "retweet_count": 0,
+  "favorite_count": 0,
+  "favorited": false,
+  "retweeted": false,
+  "lang": "tl"
+}

+ 125 - 124
app/src/providers/mock-provider/tweet.json

@@ -1,4 +1,88 @@
 [
+{
+  "created_at": "Wed Sep 25 19:54:41 +0000 2019",
+  "id": 1176948153297362949,
+  "id_str": "1176948153297362949",
+  "full_text": "Providing mock tweets",
+  "truncated": false,
+  "display_text_range": [
+    0,
+    6
+  ],
+  "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,
+  "user":
+  {
+    "id": 1176099783947235328,
+    "id_str": "1176099783947235328",
+    "name": "User1",
+    "screen_name": "test_user1",
+    "location": "",
+    "description": "",
+    "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": "assets/imgs/logo.png",
+    "profile_image_url_https": "assets/imgs/logo.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"
+  },
+  "geo": null,
+  "coordinates": null,
+  "place": null,
+  "contributors": null,
+  "is_quote_status": false,
+  "retweet_count": 0,
+  "favorite_count": 0,
+  "favorited": false,
+  "retweeted": false,
+  "lang": "tl"
+},
 {
   "created_at": "Wed Sep 25 19:54:41 +0000 2019",
   "id": 1176948153297362940,
@@ -24,10 +108,10 @@
   "in_reply_to_screen_name": null,
   "user":
   {
-    "id": 1176099783947235328,
-    "id_str": "1176099783947235328",
-    "name": "Thesis test",
-    "screen_name": "test_thesis",
+    "id": 1176099783947235338,
+    "id_str": "1176099783947235338",
+    "name": "User2",
+    "screen_name": "test_user2",
     "location": "",
     "description": "",
     "url": null,
@@ -57,8 +141,8 @@
     "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_image_url": "assets/imgs/user2.png",
+    "profile_image_url_https": "assets/imgs/user2.png",
     "profile_link_color": "1DA1F2",
     "profile_sidebar_border_color": "C0DEED",
     "profile_sidebar_fill_color": "DDEEF6",
@@ -112,13 +196,14 @@
   "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":
+  "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": [],
@@ -141,16 +226,16 @@
     "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",
+      "id": 1176099783947235348,
+      "id_str": "1176099783947235348",
+      "name": "User3",
+      "screen_name": "test_user3",
       "location": "",
       "description": "tweet://1192026901956583424 #hybridOSN",
       "url": null,
       "entities":
       {
-        
+
         "description":
         {
           "urls": []
@@ -175,8 +260,8 @@
       "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_image_url": "assets/imgs/user3.png",
+      "profile_image_url_https": "assets/imgs/user3.png",
       "profile_link_color": "1DA1F2",
       "profile_sidebar_border_color": "C0DEED",
       "profile_sidebar_fill_color": "DDEEF6",
@@ -189,96 +274,13 @@
       "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,
-  "id_str": "1176948153297362947",
-  "full_text": "Thesis hosn",
-  "private_tweet": true,
-  "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,
   "user":
   {
-    "id": 1176099783947235328,
-    "id_str": "1176099783947235328",
+    "id": 1176099783947235358,
+    "id_str": "1176099783947235358",
     "name": "Thesis test",
     "screen_name": "test_thesis",
     "location": "",
@@ -286,7 +288,7 @@
     "url": null,
     "entities":
     {
-      
+
       "description":
       {
         "urls": []
@@ -311,8 +313,8 @@
     "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_image_url": "assets/imgs/jd.png",
+    "profile_image_url_https": "assets/imgs/jd.png",
     "profile_link_color": "1DA1F2",
     "profile_sidebar_border_color": "C0DEED",
     "profile_sidebar_fill_color": "DDEEF6",
@@ -326,11 +328,8 @@
     "notifications": false,
     "translator_type": "none"
   },
-  "geo": null,
-  "coordinates": null,
-  "place": null,
-  "contributors": null,
-  "is_quote_status": false,
+  "quoted_status_id": 1192024317871046700,
+  "quoted_status_id_str": "1192024317871046656",
   "retweet_count": 0,
   "favorite_count": 0,
   "favorited": false,
@@ -338,14 +337,15 @@
   "lang": "tl"
 },
 {
-  "created_at": "Wed Sep 25 19:54:41 +0000 2019",
-  "id": 1176948153297362949,
-  "id_str": "1176948153297362949",
-  "full_text": "Providing mock tweets",
+  "created_at": "Wed Sep 29 19:54:41 +0000 2019",
+  "id": 1176948153297362947,
+  "id_str": "1176948153297362947",
+  "full_text": "Private tweet",
+  "private_tweet": true,
   "truncated": false,
   "display_text_range": [
     0,
-    6
+    13
   ],
   "entities":
   {
@@ -362,15 +362,16 @@
   "in_reply_to_screen_name": null,
   "user":
   {
-    "id": 1176099783947235328,
-    "id_str": "1176099783947235328",
+    "id": 1176099783947235358,
+    "id_str": "1176099783947235358",
     "name": "Thesis test",
     "screen_name": "test_thesis",
     "location": "",
-    "description": "",
+    "description": "tweet://1192026901956583424 #hybridOSN",
     "url": null,
     "entities":
     {
+
       "description":
       {
         "urls": []
@@ -395,8 +396,8 @@
     "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_image_url": "assets/imgs/jd.png",
+    "profile_image_url_https": "assets/imgs/jd.png",
     "profile_link_color": "1DA1F2",
     "profile_sidebar_border_color": "C0DEED",
     "profile_sidebar_fill_color": "DDEEF6",

+ 1 - 1
app/src/providers/p2p-database-gun/p2p-database-gun.ts

@@ -15,7 +15,7 @@ export class P2pDatabaseGunProvider {
    * Hashtags are stored without reference to the users to provide these information on an extra dashboard to twitter
    * @param hashtagEntity extracted hashtags
    */
-  public async publishHashtags(hashtagEntity): Promise <void> {
+  public async publishHashtags(hashtagEntity): Promise < void > {
     const timestamp = new Date().setHours(0, 0, 1, 0);
     const hashtagsSeparated = hashtagEntity
       .map(el => el.hashtag)

Some files were not shown because too many files changed in this diff