about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/util/stream.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-05-27 17:10:48 +0200
committerThibG <thib@sitedethib.com>2018-05-27 20:39:25 +0200
commit1fa3586db5d2e56480536377fea8bc52672e0516 (patch)
treea9d0bf9ec55c304afe7aca7adc44bed726c36004 /app/javascript/flavours/glitch/util/stream.js
parentd959d04133e619955100c58bc21e157f18db1fb1 (diff)
[Glitch] Use streaming API for standalone timelines on /about and /tag pages
Port 0128b86d3098042cdbc3a1629f74b70f665f8dfb to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/util/stream.js')
-rw-r--r--app/javascript/flavours/glitch/util/stream.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/util/stream.js b/app/javascript/flavours/glitch/util/stream.js
index 36c68ffc5..9a6f4f26d 100644
--- a/app/javascript/flavours/glitch/util/stream.js
+++ b/app/javascript/flavours/glitch/util/stream.js
@@ -62,7 +62,13 @@ export function connectStream(path, pollingRefresh = null, callbacks = () => ({
 
 
 export default function getStream(streamingAPIBaseURL, accessToken, stream, { connected, received, disconnected, reconnected }) {
-  const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?access_token=${accessToken}&stream=${stream}`);
+  const params = [ `stream=${stream}` ];
+
+  if (accessToken !== null) {
+    params.push(`access_token=${accessToken}`);
+  }
+
+  const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`);
 
   ws.onopen      = connected;
   ws.onmessage   = e => received(JSON.parse(e.data));