Add streaming for local timeline and friends TL.
This commit is contained in:
parent
676989dd70
commit
59626efadc
|
@ -1,4 +1,4 @@
|
|||
import { camelCase } from 'lodash'
|
||||
import { camelCase, includes } from 'lodash'
|
||||
|
||||
import apiService from '../api/api.service.js'
|
||||
import { parseStatus } from '../entity_normalizer/entity_normalizer.service.js'
|
||||
|
@ -42,10 +42,16 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false
|
|||
const streamTimeline = ({timeline, store, userId}) => {
|
||||
const rootState = store.rootState || store.state
|
||||
const timelines = {
|
||||
publicAndExternal: 'public'
|
||||
publicAndExternal: 'public',
|
||||
public: 'public:local',
|
||||
friends: 'user'
|
||||
}
|
||||
|
||||
const url = `${rootState.instance.server}/api/v1/streaming?stream=${timelines[timeline]}`.replace('http', 'ws')
|
||||
let url = `${rootState.instance.server}/api/v1/streaming?stream=${timelines[timeline]}`.replace('http', 'ws')
|
||||
|
||||
if (rootState.oauth.token) {
|
||||
url = url + `&access_token=${rootState.oauth.token}`
|
||||
}
|
||||
|
||||
const socket = new window.WebSocket(url)
|
||||
|
||||
|
@ -72,7 +78,9 @@ const startFetching = ({timeline = 'friends', credentials, store, userId = false
|
|||
timelineData.userId = userId
|
||||
fetchAndUpdate({timeline, credentials, store, showImmediately, userId, tag})
|
||||
|
||||
if (timeline === 'publicAndExternal') {
|
||||
const websocketTimelines = ['publicAndExternal', 'public', 'friends']
|
||||
|
||||
if (includes(websocketTimelines, timeline)) {
|
||||
return streamTimeline({timeline, store, userId})
|
||||
} else {
|
||||
const boundFetchAndUpdate = () => fetchAndUpdate({ timeline, credentials, store, userId, tag })
|
||||
|
|
Loading…
Reference in New Issue