Skip to content

Commit

Permalink
Update timeline.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Aug 11, 2023
1 parent a3a5968 commit 2637adc
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/classes/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,22 @@ export default class Timeline {
cookie: null
}
) {
// Ensure its a string to form a valid endpoint.
const proxy = options.proxyUrl ?? `https://corsproxy.io/?`

const endpoint = `${proxy}${this.url}${username}?showReplies=true`
const timeline = await this.#fetchUserTimeline(endpoint, options.cookie)
const proxy = options.proxyUrl ?? `https://corsproxy.io/?`,
endpoint = `${proxy}${this.url}${username}?showReplies=true`,
timeline = await this.#fetchUserTimeline(endpoint, options.cookie)

// TODO: Properly handle error
if (!timeline) return

const includeReplies = options.replies || false
const includeRts = options.retweets || false
const includeReplies = options.replies || false,
includeRts = options.retweets || false

const tweets = timeline.map(e => new TimelineTweet(e.content.tweet))

// if (tweets.length < 1) {
// // Throw error
// }

return tweets.filter(twt =>
(twt.isRetweet === includeRts) &&
(twt.isReply === includeReplies)
Expand Down

0 comments on commit 2637adc

Please sign in to comment.