Start fetching user timelines.
This commit is contained in:
parent
85cf036acd
commit
090148ef60
7 changed files with 55 additions and 16 deletions
|
@ -18,6 +18,7 @@ const FOLLOWING_URL = '/api/friendships/create.json'
|
|||
const UNFOLLOWING_URL = '/api/friendships/destroy.json'
|
||||
const QVITTER_USER_PREF_URL = '/api/qvitter/set_profile_pref.json'
|
||||
const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
|
||||
const QVITTER_USER_TIMELINE_URL = '/api/qvitter/statuses/user_timeline.json'
|
||||
// const USER_URL = '/api/users/show.json'
|
||||
|
||||
const oldfetch = window.fetch
|
||||
|
@ -98,24 +99,34 @@ const setUserMute = ({id, credentials, muted = true}) => {
|
|||
})
|
||||
}
|
||||
|
||||
const fetchTimeline = ({timeline, credentials, since = false, until = false}) => {
|
||||
const fetchTimeline = ({timeline, credentials, since = false, until = false, userId = false}) => {
|
||||
const timelineUrls = {
|
||||
public: PUBLIC_TIMELINE_URL,
|
||||
friends: FRIENDS_TIMELINE_URL,
|
||||
mentions: MENTIONS_URL,
|
||||
'publicAndExternal': PUBLIC_AND_EXTERNAL_TIMELINE_URL
|
||||
'publicAndExternal': PUBLIC_AND_EXTERNAL_TIMELINE_URL,
|
||||
user: QVITTER_USER_TIMELINE_URL
|
||||
}
|
||||
|
||||
let url = timelineUrls[timeline]
|
||||
|
||||
let params = []
|
||||
|
||||
if (since) {
|
||||
url += `?since_id=${since}`
|
||||
params.push('since_id', since)
|
||||
}
|
||||
|
||||
if (until) {
|
||||
url += `?max_id=${until}`
|
||||
params.push('max_id', until)
|
||||
}
|
||||
|
||||
if (userId) {
|
||||
params.push(['user_id', userId])
|
||||
}
|
||||
|
||||
const queryString = new URLSearchParams(params).toString()
|
||||
url += `?${queryString}`
|
||||
|
||||
return fetch(url, { headers: authHeaders(credentials) }).then((data) => data.json())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue