|
@@ -15,6 +15,7 @@ class Server {
|
|
async getLatestTweets(username: string, interval: number = 600): Promise<Tweet[]> {
|
|
async getLatestTweets(username: string, interval: number = 600): Promise<Tweet[]> {
|
|
const storedAuthorId = this.store.getAuthorId(username);
|
|
const storedAuthorId = this.store.getAuthorId(username);
|
|
const latestTweet = storedAuthorId === null ? null : this.store.getLatestTweet(storedAuthorId);
|
|
const latestTweet = storedAuthorId === null ? null : this.store.getLatestTweet(storedAuthorId);
|
|
|
|
+ let authorId = storedAuthorId;
|
|
|
|
|
|
let timeline = await this.client.getTimeline(username, latestTweet?.id_str);
|
|
let timeline = await this.client.getTimeline(username, latestTweet?.id_str);
|
|
console.log(`Fetched ${timeline.length} new tweets`);
|
|
console.log(`Fetched ${timeline.length} new tweets`);
|
|
@@ -35,7 +36,12 @@ class Server {
|
|
const lastTweet = timeline[timeline.length - 1];
|
|
const lastTweet = timeline[timeline.length - 1];
|
|
const olderTweets = this.store.getLatestTweets(lastTweet.user.id_str, lastTweet.id_str, newerThan);
|
|
const olderTweets = this.store.getLatestTweets(lastTweet.user.id_str, lastTweet.id_str, newerThan);
|
|
timeline = timeline.concat(olderTweets);
|
|
timeline = timeline.concat(olderTweets);
|
|
|
|
+ authorId = lastTweet.user.id_str;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ timeline = timeline.filter(({ in_reply_to_user_id_str }) => {
|
|
|
|
+ return in_reply_to_user_id_str === null || in_reply_to_user_id_str === authorId;
|
|
|
|
+ });
|
|
return timeline;
|
|
return timeline;
|
|
}
|
|
}
|
|
|
|
|