#468 - show pinned timeline and add pinned label to the status

This commit is contained in:
dave 2019-04-04 15:10:34 -04:00 committed by taehoon
parent e28b19645a
commit 2c89d49a3d
11 changed files with 69 additions and 18 deletions

View file

@ -506,6 +506,19 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, use
.then((data) => data.map(isNotifications ? parseNotification : parseStatus))
}
const fetchPinnedStatuses = ({ id, credentials }) => {
const url = MASTODON_USER_TIMELINE_URL(id) + '?pinned=true'
return fetch(url, { headers: authHeaders(credentials) })
.then((data) => {
if (data.ok) {
return data
}
throw new Error('Error fetching pinned timeline', data)
})
.then((data) => data.json())
.then((data) => data.map(parseStatus))
}
const verifyCredentials = (user) => {
return fetch(LOGIN_URL, {
method: 'POST',
@ -726,6 +739,7 @@ const reportUser = ({credentials, userId, statusIds, comment, forward}) => {
const apiService = {
verifyCredentials,
fetchTimeline,
fetchPinnedStatuses,
fetchConversation,
fetchStatus,
fetchFriends,

View file

@ -16,6 +16,12 @@ const update = ({store, statuses, timeline, showImmediately, userId}) => {
}
const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false, userId = false, tag = false, until}) => {
if (timeline === 'pinned') {
return apiService.fetchPinnedStatuses({ id: userId, credentials })
.then(statuses => {
update({ store, statuses, timeline, showImmediately, userId })
})
}
const args = { timeline, credentials }
const rootState = store.rootState || store.state
const timelineData = rootState.statuses.timelines[camelCase(timeline)]