Skip to content

🎧 Your Personal Streaming Service

Only setup event stream when mounting the app

Deluana77635e883cf
diff --git a/ui/src/App.js b/ui/src/App.js
index 9e224f7cf..1389a24ec 100644
--- a/ui/src/App.js
+++ b/ui/src/App.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import React, { useEffect } from 'react'
import ReactGA from 'react-ga'
import 'react-jinke-music-player/assets/index.css'
import { Provider, useDispatch } from 'react-redux'
@@ -65,13 +65,15 @@ const App = () => (
const Admin = (props) => {
useChangeThemeColor()
const dispatch = useDispatch()
- if (config.devActivityPanel) {
- setDispatch(dispatch)
- authProvider
- .checkAuth()
- .then(() => startEventStream())
- .catch(() => {}) // ignore if not logged in
- }
+ useEffect(() => {
+ if (config.devActivityPanel) {
+ setDispatch(dispatch)
+ authProvider
+ .checkAuth()
+ .then(() => startEventStream())
+ .catch(() => {}) // ignore if not logged in
+ }
+ }, [dispatch])
return (
<RAAdmin
diff --git a/ui/src/eventStream.js b/ui/src/eventStream.js
index 6faed3573..32471c8df 100644
--- a/ui/src/eventStream.js
+++ b/ui/src/eventStream.js
@@ -14,7 +14,7 @@ let timeout = null
const getEventStream = async () => {
if (!es) {
// Call `keepalive` to refresh the jwt token
- await httpClient(`${REST_URL}/keepalive/eventSource`)
+ await httpClient(`${REST_URL}/keepalive/keepalive`)
es = new EventSource(
baseUrl(`${REST_URL}/events?jwt=${localStorage.getItem('token')}`)
)