Skip to content

Commit

Permalink
Added more statuses and websocket url by env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Jnegrier committed Sep 13, 2020
1 parent 96fe64f commit c4bee40
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion hooks/useSocket.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react'
import io from 'socket.io-client'

const socket = io("http://localhost:8080")
const socket = io(process.env.publicDeltaWebsockets)

export default function useSocket(eventName, cb) {
useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ module.exports = withCSS({
env: {
deltaCore: process.env.DELTA_CORE_URL,
publicDeltaCore: process.env.PUBLIC_DELTA_CORE_URL,
publicDeltaWebsockets: process.env.PUBLIC_DELTA_WEBSOCKETS_URL,
},
})
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MyApp extends App<Props> {
jssStyles.parentNode.removeChild(jssStyles)
}
// connect to Websockets server and listen for events
const socket = io("http://localhost:8080")
const socket = io(process.env.publicDeltaWebsockets)
this.setState({ socket })
}

Expand Down
18 changes: 16 additions & 2 deletions pages/launches/[launchesByProjectId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,21 @@ function Launches(props: Props) {
useSocket('delta_launch', testLaunch => {
// setNotification(1);
if (props.launches[0].project_id == testLaunch.project_id) {
let msg = "🚀 There is a new launch: " + testLaunch.name
let msg: string;
switch(testLaunch.launch_status) {
case "Failed": {
msg = "💥 Launch Failed: " + testLaunch.name
break;
}
case "Successful": {
msg = "✨ Launch Successful: " + testLaunch.name
break;
}
default: {
msg = "🚀 There is a new launch: " + testLaunch.name
break;
}
}
setNotificationState({ ...notificationState, open: true, message: msg });
}
})
Expand Down Expand Up @@ -211,7 +225,7 @@ function Launches(props: Props) {
open={open}
onClose={handleCloseNotification}
message={message}
autoHideDuration={3000}
autoHideDuration={5000}
action={
<React.Fragment>
<Tooltip title="Reload page">
Expand Down

0 comments on commit c4bee40

Please sign in to comment.