Add list timeline rendering functionality
the list name is missing; this is because the API request to get it is different to the API request for receiving the list timeline, and is not yet implemented.
This commit is contained in:
parent
c1a8dc34da
commit
d5d464a289
9 changed files with 62 additions and 11 deletions
|
@ -50,6 +50,7 @@ const MASTODON_STATUS_CONTEXT_URL = id => `/api/v1/statuses/${id}/context`
|
|||
const MASTODON_USER_URL = '/api/v1/accounts'
|
||||
const MASTODON_USER_RELATIONSHIPS_URL = '/api/v1/accounts/relationships'
|
||||
const MASTODON_USER_TIMELINE_URL = id => `/api/v1/accounts/${id}/statuses`
|
||||
const MASTODON_LIST_TIMELINE_URL = id => `/api/v1/timelines/list/${id}`
|
||||
const MASTODON_TAG_TIMELINE_URL = tag => `/api/v1/timelines/tag/${tag}`
|
||||
const MASTODON_BOOKMARK_TIMELINE_URL = '/api/v1/bookmarks'
|
||||
const MASTODON_USER_BLOCKS_URL = '/api/v1/blocks/'
|
||||
|
@ -503,6 +504,7 @@ const fetchTimeline = ({
|
|||
since = false,
|
||||
until = false,
|
||||
userId = false,
|
||||
listId = false,
|
||||
tag = false,
|
||||
withMuted = false,
|
||||
replyVisibility = 'all'
|
||||
|
@ -515,6 +517,7 @@ const fetchTimeline = ({
|
|||
'publicAndExternal': MASTODON_PUBLIC_TIMELINE,
|
||||
user: MASTODON_USER_TIMELINE_URL,
|
||||
media: MASTODON_USER_TIMELINE_URL,
|
||||
list: MASTODON_LIST_TIMELINE_URL,
|
||||
favorites: MASTODON_USER_FAVORITES_TIMELINE_URL,
|
||||
tag: MASTODON_TAG_TIMELINE_URL,
|
||||
bookmarks: MASTODON_BOOKMARK_TIMELINE_URL
|
||||
|
@ -528,6 +531,10 @@ const fetchTimeline = ({
|
|||
url = url(userId)
|
||||
}
|
||||
|
||||
if (timeline === 'list') {
|
||||
url = url(listId)
|
||||
}
|
||||
|
||||
if (since) {
|
||||
params.push(['since_id', since])
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ import notificationsFetcher from '../notifications_fetcher/notifications_fetcher
|
|||
import followRequestFetcher from '../../services/follow_request_fetcher/follow_request_fetcher.service'
|
||||
|
||||
const backendInteractorService = credentials => ({
|
||||
startFetchingTimeline ({ timeline, store, userId = false, tag }) {
|
||||
return timelineFetcher.startFetching({ timeline, store, credentials, userId, tag })
|
||||
startFetchingTimeline ({ timeline, store, userId = false, listId = false, tag }) {
|
||||
return timelineFetcher.startFetching({ timeline, store, credentials, userId, listId, tag })
|
||||
},
|
||||
|
||||
fetchTimeline (args) {
|
||||
|
|
|
@ -3,12 +3,13 @@ import { camelCase } from 'lodash'
|
|||
import apiService from '../api/api.service.js'
|
||||
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
||||
|
||||
const update = ({ store, statuses, timeline, showImmediately, userId, pagination }) => {
|
||||
const update = ({ store, statuses, timeline, showImmediately, userId, listId, pagination }) => {
|
||||
const ccTimeline = camelCase(timeline)
|
||||
|
||||
store.dispatch('addNewStatuses', {
|
||||
timeline: ccTimeline,
|
||||
userId,
|
||||
listId,
|
||||
statuses,
|
||||
showImmediately,
|
||||
pagination
|
||||
|
@ -22,6 +23,7 @@ const fetchAndUpdate = ({
|
|||
older = false,
|
||||
showImmediately = false,
|
||||
userId = false,
|
||||
listId = false,
|
||||
tag = false,
|
||||
until,
|
||||
since
|
||||
|
@ -44,6 +46,7 @@ const fetchAndUpdate = ({
|
|||
}
|
||||
|
||||
args['userId'] = userId
|
||||
args['listId'] = listId
|
||||
args['tag'] = tag
|
||||
args['withMuted'] = !hideMutedPosts
|
||||
if (loggedIn && ['friends', 'public', 'publicAndExternal'].includes(timeline)) {
|
||||
|
@ -62,7 +65,7 @@ const fetchAndUpdate = ({
|
|||
if (!older && statuses.length >= 20 && !timelineData.loading && numStatusesBeforeFetch > 0) {
|
||||
store.dispatch('queueFlush', { timeline: timeline, id: timelineData.maxId })
|
||||
}
|
||||
update({ store, statuses, timeline, showImmediately, userId, pagination })
|
||||
update({ store, statuses, timeline, showImmediately, userId, listId, pagination })
|
||||
return { statuses, pagination }
|
||||
})
|
||||
.catch((error) => {
|
||||
|
@ -75,14 +78,15 @@ const fetchAndUpdate = ({
|
|||
})
|
||||
}
|
||||
|
||||
const startFetching = ({ timeline = 'friends', credentials, store, userId = false, tag = false }) => {
|
||||
const startFetching = ({ timeline = 'friends', credentials, store, userId = false, listId = false, tag = false }) => {
|
||||
const rootState = store.rootState || store.state
|
||||
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
|
||||
const showImmediately = timelineData.visibleStatuses.length === 0
|
||||
timelineData.userId = userId
|
||||
fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag })
|
||||
timelineData.listId = listId
|
||||
fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, listId, tag })
|
||||
const boundFetchAndUpdate = () =>
|
||||
fetchAndUpdate({ timeline, credentials, store, userId, tag })
|
||||
fetchAndUpdate({ timeline, credentials, store, userId, listId, tag })
|
||||
return promiseInterval(boundFetchAndUpdate, 20000)
|
||||
}
|
||||
const timelineFetcher = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue