Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add fallbacks when services offline
Browse files Browse the repository at this point in the history
mdvanes committed Mar 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 86e339c commit e036d43
Showing 4 changed files with 28 additions and 4 deletions.
12 changes: 10 additions & 2 deletions apps/client/src/Components/Molecules/DockerList/DockerList.tsx
Original file line number Diff line number Diff line change
@@ -21,21 +21,29 @@ interface DockerListProps {

const DockerList: FC<DockerListProps> = ({ onError }) => {
const [isOpen, setIsOpen] = useState(false);
const [isSkippingBecauseError, setIsSkippingBecauseError] = useState(false);
const { data, isLoading, isFetching, error } = useGetDockerListQuery(
undefined,
{
pollingInterval: UPDATE_INTERVAL_MS,
pollingInterval: isSkippingBecauseError
? undefined
: UPDATE_INTERVAL_MS,
}
);

useEffect(() => {
if (error) {
setIsSkippingBecauseError(true);
onError(getErrorMessage(error));
}
}, [error, onError]);

if (error) {
return <Alert severity="error">{getErrorMessage(error)}</Alert>;
return (
<Box mx={-2}>
<Alert severity="error">{getErrorMessage(error)}</Alert>
</Box>
);
}

if (data?.status !== "received") {
Original file line number Diff line number Diff line change
@@ -11,18 +11,22 @@ const UPDATE_INTERVAL_MS = 30000;

const DownloadList: FC = () => {
const [isOpen, setIsOpen] = useState(false);
const [isSkippingBecauseError, setIsSkippingBecauseError] = useState(false);
const dispatch = useAppDispatch();

const { data, error, isLoading, isFetching } = useGetDownloadListQuery(
undefined,
{
pollingInterval: UPDATE_INTERVAL_MS,
pollingInterval: isSkippingBecauseError
? undefined
: UPDATE_INTERVAL_MS,
}
);
const [listItems, setListItems] = useState<JSX.Element[]>([]);

useEffect(() => {
if (error) {
setIsSkippingBecauseError(true);
dispatch(logError("GetDownloadList failed"));
}
}, [dispatch, error]);
4 changes: 3 additions & 1 deletion apps/client/src/Components/Pages/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -49,7 +49,9 @@ const Dashboard: FC = () => {
<Grid item xs={12} md>
<StreamContainer />
<Jukebox />
<VideoStream />
{(localStorage.getItem("showVideoStream") ?? "") === "true" ? (
<VideoStream />
) : undefined}
<CarTabs />
<IconButton
color="primary"
10 changes: 10 additions & 0 deletions apps/server/src/energyusage/energyusage.controller.ts
Original file line number Diff line number Diff line change
@@ -44,6 +44,16 @@ const temperatureResponseToEntry =
(response: GotTempResponse, temperatureIndex: number) => {
const sensor = temperatureSensors[temperatureIndex];
const temperatureEntry = response.result[index];
if (!temperatureEntry) {
return [
sensor.name,
{
avg: undefined,
high: undefined,
low: undefined,
},
];
}
if (temperatureEntry.d !== temperatureEntry.d) {
throw new Error("days do not match");
}

0 comments on commit e036d43

Please sign in to comment.