Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions src/Pages/LedSign/LedSign.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useState, useEffect } from 'react';
import { healthCheck, updateSignText } from '../../APIFunctions/LedSign';
import { useUser } from '../../Components/context/UserContext';

import './ledsign.css';


function LedSign(props) {
function LedSign() {
const { user } = useUser();
const [signHealthy, setSignHealthy] = useState(false);
const [loading, setLoading] = useState(true);
const [text, setText] = useState('');
Expand Down Expand Up @@ -69,10 +70,6 @@ function LedSign(props) {

async function handleSend() {
setAwaitingSignResponse(true);
// on the led sign server, a lower value for scroll speed means that
// the message scrolls faster. In the frontend, the speed input can be
// from 0 to 10. If the speed is 0, the sign doesn't stop, but instead
// just scrolls really fast.
let correctedScrollSpeed = 10 - scrollSpeed;
const signResponse = await updateSignText(
{
Expand All @@ -82,10 +79,10 @@ function LedSign(props) {
backgroundColor,
textColor,
borderColor,
email: props.user.email,
firstName: props.user.firstName,
email: user.email,
firstName: user.firstName,
},
props.user.token
user.token
);
setRequestSuccessful(!signResponse.error);
setAwaitingSignResponse(false);
Expand All @@ -96,10 +93,10 @@ function LedSign(props) {
const signResponse = await updateSignText(
{
ledIsOff: true,
email: props.user.email,
firstName: props.user.firstName,
email: user.email,
firstName: user.firstName,
},
props.user.token
user.token
);
setStopRequestSuccesful(!signResponse.error);
setAwaitingStopSignResponse(false);
Expand All @@ -122,7 +119,7 @@ function LedSign(props) {
useEffect(() => {
async function checkSignHealth() {
setLoading(true);
const status = await healthCheck(props.user.firstName);
const status = await healthCheck(user.firstName);
if (status && !status.error) {
setSignHealthy(true);
const { responseData } = status;
Expand All @@ -139,7 +136,7 @@ function LedSign(props) {
}
setLoading(false);
}
checkSignHealth(props.user.firstName);
checkSignHealth();
// eslint-disable-next-line
}, [])

Expand Down