[Glitch] Allow clients to fetch statuses made while they were offline

Port 9a1a55ce52 to glitch-soc
This commit is contained in:
Thibaut Girka
2018-05-27 19:10:37 +02:00
committed by ThibG
parent 532fb8e215
commit 0ad3eedd4c
21 changed files with 195 additions and 261 deletions

View File

@@ -1,10 +1,10 @@
import WebSocketClient from 'websocket.js';
export function connectStream(path, pollingRefresh = null, callbacks = () => ({ onConnect() {}, onDisconnect() {}, onReceive() {} })) {
export function connectStream(path, pollingRefresh = null, callbacks = () => ({ onDisconnect() {}, onReceive() {} })) {
return (dispatch, getState) => {
const streamingAPIBaseURL = getState().getIn(['meta', 'streaming_api_base_url']);
const accessToken = getState().getIn(['meta', 'access_token']);
const { onConnect, onDisconnect, onReceive } = callbacks(dispatch, getState);
const { onDisconnect, onReceive } = callbacks(dispatch, getState);
let polling = null;
const setupPolling = () => {
@@ -25,7 +25,6 @@ export function connectStream(path, pollingRefresh = null, callbacks = () => ({
if (pollingRefresh) {
clearPolling();
}
onConnect();
},
disconnected () {
@@ -44,7 +43,6 @@ export function connectStream(path, pollingRefresh = null, callbacks = () => ({
clearPolling();
pollingRefresh(dispatch);
}
onConnect();
},
});