Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide overlay when no initial response fronm it #600

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
12 changes: 8 additions & 4 deletions gui/src/components/widgets/OverlayWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { useEffect } from 'react';
import { useLocalization } from '@fluent/react';
import { useEffect, useState } from 'react';
import { useForm } from 'react-hook-form';
import { KeyValuesT, MessageT, Payload, Topic } from 'solarxr-protocol';
import {
OVERLAY_DISPLAY_SETTINGS_TOPIC,
PayloadData,
usePubSub,
usePubSub
} from '../../hooks/pubSub';
import { CheckBox } from '../commons/Checkbox';
import { useLocalization } from '@fluent/react';
import { Typography } from '../commons/Typography';

export function OverlayWidget() {
const { l10n } = useLocalization();
const { publish, subscribe, keyValues } = usePubSub();
const [loading, setLoading] = useState(true);
const { reset, control, handleSubmit, watch } = useForm<{
isVisible: boolean;
isMirrored: boolean;
Expand All @@ -26,6 +27,7 @@ export function OverlayWidget() {
subscribe(
OVERLAY_DISPLAY_SETTINGS_TOPIC,
(payload: PayloadData, type: Payload) => {
setLoading(false);
if (type !== Payload.KeyValues) throw new Error('Invalid payload');
const obj = keyValues(payload);
reset({
Expand Down Expand Up @@ -63,7 +65,7 @@ export function OverlayWidget() {
publish(message);
};

return (
return !loading ? (
<form className="bg-background-60 flex flex-col w-full rounded-md px-2">
<div className="mt-2 px-1">
<Typography color="secondary">
Expand All @@ -83,5 +85,7 @@ export function OverlayWidget() {
label={l10n.getString('widget-overlay-is_mirrored_label')}
></CheckBox>
</form>
) : (
<></>
);
}