Fix streaming access token
This commit is contained in:
parent
94da1f6722
commit
74f48229fc
3 changed files with 8 additions and 2 deletions
|
@ -40,6 +40,7 @@ import Icon from 'soapbox/components/icon';
|
|||
import { isStaff } from 'soapbox/utils/accounts';
|
||||
import ChatPanes from 'soapbox/features/chats/components/chat_panes';
|
||||
import ProfileHoverCard from 'soapbox/components/profile_hover_card';
|
||||
import { getAccessToken } from 'soapbox/utils/auth';
|
||||
|
||||
import {
|
||||
Status,
|
||||
|
@ -111,7 +112,7 @@ const mapStateToProps = state => {
|
|||
hasComposingText: state.getIn(['compose', 'text']).trim().length !== 0,
|
||||
hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0,
|
||||
dropdownMenuIsOpen: state.getIn(['dropdown_menu', 'openId']) !== null,
|
||||
accessToken: state.getIn(['auth', 'user', 'access_token']),
|
||||
accessToken: getAccessToken(state),
|
||||
streamingUrl: state.getIn(['instance', 'urls', 'streaming_api']),
|
||||
me,
|
||||
account,
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
import WebSocketClient from 'websocket.js';
|
||||
import { getAccessToken } from 'soapbox/utils/auth';
|
||||
|
||||
const randomIntUpTo = max => Math.floor(Math.random() * Math.floor(max));
|
||||
|
||||
export function connectStream(path, pollingRefresh = null, callbacks = () => ({ onConnect() {}, onDisconnect() {}, onReceive() {} })) {
|
||||
return (dispatch, getState) => {
|
||||
const streamingAPIBaseURL = getState().getIn(['instance', 'urls', 'streaming_api']);
|
||||
const accessToken = getState().getIn(['auth', 'user', 'access_token']);
|
||||
const accessToken = getAccessToken(getState());
|
||||
const { onConnect, onDisconnect, onReceive } = callbacks(dispatch, getState);
|
||||
|
||||
let polling = null;
|
||||
|
|
4
app/soapbox/utils/auth.js
Normal file
4
app/soapbox/utils/auth.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
export const getAccessToken = state => {
|
||||
const me = state.getIn(['auth', 'me']);
|
||||
return state.getIn(['auth', 'users', me, 'access_token']);
|
||||
};
|
Loading…
Reference in a new issue