diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index b0c8769a7b..faaec66933 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -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 })