Carsten Porth 6 lat temu
rodzic
commit
0642ecd6fe

+ 6 - 8
app/src/pages/home/home.ts

@@ -62,14 +62,12 @@ export class HomePage {
   }
 
   loadMore(infiniteScroll: InfiniteScroll) {
-    this.twitter
-      .fetchHomeFeedSince(this.data[this.data.length - 1].id)
-      .then(res => {
-        this.data = this.data
-          .concat(res.data)
-          .sort((a, b) => this.sortByDateAsc(a, b));
-        infiniteScroll.complete();
-      });
+    this.twitter.fetchHomeFeed(this.data[this.data.length - 1].id).then(res => {
+      this.data = this.data
+        .concat(res.data)
+        .sort((a, b) => this.sortByDateAsc(a, b));
+      infiniteScroll.complete();
+    });
   }
 
   writeTweet() {

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

@@ -111,13 +111,10 @@ export class ProfilePage {
 
   private async loadTimeline(userId, oldestLoadedTweetId?) {
     // Fetch tweets from Twitter
-    const tweets =
-      oldestLoadedTweetId == null
-        ? await this.twitter.fetchUserTimeline(userId)
-        : await this.twitter.fetchUserTimelineSince(
-            userId,
-            oldestLoadedTweetId
-          );
+    const tweets = await this.twitter.fetchUserTimeline(
+      userId,
+      oldestLoadedTweetId
+    );
 
     // Determine end of time interval to look for private tweets
     let intervalEnd: Date;
@@ -133,6 +130,7 @@ export class ProfilePage {
     // Fetch private tweet hashs from P2P DB for corresponding interval
     const privateTweetHashs: string[] = await this.gun.fetchPrivateTweetHashsForUserInInterval(
       userId,
+      // TODO: timestamp vom vorigen oldestLoadedTweet statt new Date()
       new Date(),
       intervalEnd
     );

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

@@ -1,7 +1,6 @@
 import { Injectable } from "@angular/core";
 import Gun from "gun/gun";
 import "gun/lib/then";
-import "gun/lib/load";
 
 /*
   Generated class for the P2pDatabaseGunProvider provider.

+ 5 - 23
app/src/providers/twitter-api/twitter-api.ts

@@ -23,20 +23,12 @@ export class TwitterApiProvider {
     });
   }
 
-  public async fetchHomeFeed() {
+  public async fetchHomeFeed(maxId?) {
     return await this.client.get("statuses/home_timeline", {
-      count: 10,
+      count: 20,
       include_entities: true,
-      tweet_mode: "extended"
-    });
-  }
-
-  public async fetchHomeFeedSince(id) {
-    return await this.client.get("statuses/home_timeline", {
-      max_id: id,
-      count: 15,
-      include_entities: true,
-      tweet_mode: "extended"
+      tweet_mode: "extended",
+      max_id: maxId
     });
   }
 
@@ -45,17 +37,7 @@ export class TwitterApiProvider {
     return res.data[0];
   }
 
-  public async fetchUserTimeline(userId) {
-    const res = await this.client.get("statuses/user_timeline", {
-      user_id: userId,
-      include_entities: true,
-      tweet_mode: "extended",
-      count: 20
-    });
-    return res.data;
-  }
-
-  public async fetchUserTimelineSince(userId, maxId) {
+  public async fetchUserTimeline(userId, maxId?) {
     const res = await this.client.get("statuses/user_timeline", {
       user_id: userId,
       max_id: maxId,