Skip to content

Commit

Permalink
Fallbacks when services offline (#81)
Browse files Browse the repository at this point in the history
* chore: add fallbacks when services offline

* chore: bump version
  • Loading branch information
mdvanes authored Mar 27, 2024
1 parent 86fb02b commit 8cd4ade
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 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
Expand Up @@ -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") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
4 changes: 3 additions & 1 deletion apps/client/src/Components/Pages/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions apps/server/src/energyusage/energyusage.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homeremote",
"version": "3.4.3",
"version": "3.4.4",
"license": "MIT",
"scripts": {
"writeGitInfo": "ts-node --project ./tsconfig.node.json writeGitInfo.ts",
Expand Down

0 comments on commit 8cd4ade

Please sign in to comment.