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

chore(project): upgrade prettier, apply format #2111

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 2 additions & 5 deletions desktop/main-app/src/window-manager/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,8 @@ export type AbstractWindows = {
};

// see: https://stackoverflow.com/questions/67114094/typescript-get-type-of-generic-class-parameter
type GetClassParameterForAbstractWindow<T extends AbstractWindow<any>> = T extends AbstractWindow<
infer R
>
? R
: unknown;
type GetClassParameterForAbstractWindow<T extends AbstractWindow<any>> =
T extends AbstractWindow<infer R> ? R : unknown;

export type IsMultiInstance<NAME extends constants.WindowsName> =
GetClassParameterForAbstractWindow<AbstractWindows[NAME]>;
Original file line number Diff line number Diff line change
Expand Up @@ -12,81 +12,81 @@ import { DeviceCheckResults } from "../utils";
import { useTranslate } from "@netless/flat-i18n";
import { withFlatServices } from "@netless/flat-pages/src/components/FlatServicesContext";

export const CameraCheckPage = withFlatServices("videoChat")(
({ videoChat: rtc }): React.ReactElement => {
const t = useTranslate();
const [devices, setDevices] = useState<Device[]>([]);
const [currentDeviceID, setCurrentDeviceID] = useState<string | null>(null);
const cameraStream = useRef<HTMLDivElement>(null);
const history = useHistory<DeviceCheckResults>();
const location = useLocation<DeviceCheckResults | undefined>();
const sp = useSafePromise();
export const CameraCheckPage = withFlatServices("videoChat")(({
videoChat: rtc,
}): React.ReactElement => {
const t = useTranslate();
const [devices, setDevices] = useState<Device[]>([]);
const [currentDeviceID, setCurrentDeviceID] = useState<string | null>(null);
const cameraStream = useRef<HTMLDivElement>(null);
const history = useHistory<DeviceCheckResults>();
const location = useLocation<DeviceCheckResults | undefined>();
const sp = useSafePromise();

const onCameraChanged = useCallback(
(deviceID: string): void => {
rtc.setCameraID(deviceID);
},
[rtc],
);
const onCameraChanged = useCallback(
(deviceID: string): void => {
rtc.setCameraID(deviceID);
},
[rtc],
);

useEffect(() => {
const updateCameraDevices = async (deviceID?: string): Promise<void> => {
const devices = await sp(rtc.getCameraDevices());
setDevices(devices);
setCurrentDeviceID(deviceID || devices[0]?.deviceId || null);
};
updateCameraDevices();
return rtc.events.on("camera-changed", updateCameraDevices);
}, [rtc, sp]);
useEffect(() => {
const updateCameraDevices = async (deviceID?: string): Promise<void> => {
const devices = await sp(rtc.getCameraDevices());
setDevices(devices);
setCurrentDeviceID(deviceID || devices[0]?.deviceId || null);
};
updateCameraDevices();
return rtc.events.on("camera-changed", updateCameraDevices);
}, [rtc, sp]);

useEffect(() => {
if (currentDeviceID && cameraStream.current) {
rtc.startCameraTest(cameraStream.current);
return () => {
rtc.stopCameraTest();
};
}
return;
}, [currentDeviceID, rtc]);
useEffect(() => {
if (currentDeviceID && cameraStream.current) {
rtc.startCameraTest(cameraStream.current);
return () => {
rtc.stopCameraTest();
};
}
return;
}, [currentDeviceID, rtc]);

return (
<DeviceCheckLayoutContainer>
<div className="camera-check-container">
<p>{t("camera")}</p>
<DeviceSelect
currentDeviceID={currentDeviceID}
devices={devices}
onChange={onCameraChanged}
/>
<div ref={cameraStream} className="camera-check-info" />
<div className="camera-check-btn">
<Button onClick={checkFail}>{t("unable-to-see")}</Button>
<Button type="primary" onClick={checkSuccess}>
{t("able-to-see")}
</Button>
</div>
return (
<DeviceCheckLayoutContainer>
<div className="camera-check-container">
<p>{t("camera")}</p>
<DeviceSelect
currentDeviceID={currentDeviceID}
devices={devices}
onChange={onCameraChanged}
/>
<div ref={cameraStream} className="camera-check-info" />
<div className="camera-check-btn">
<Button onClick={checkFail}>{t("unable-to-see")}</Button>
<Button type="primary" onClick={checkSuccess}>
{t("able-to-see")}
</Button>
</div>
</DeviceCheckLayoutContainer>
);
</div>
</DeviceCheckLayoutContainer>
);

function checkSuccess(): void {
history.push({
pathname: routeConfig.SpeakerCheckPage.path,
state: {
...location.state,
cameraCheck: { content: "", hasError: false },
},
});
}
function checkSuccess(): void {
history.push({
pathname: routeConfig.SpeakerCheckPage.path,
state: {
...location.state,
cameraCheck: { content: "", hasError: false },
},
});
}

function checkFail(): void {
history.push({
pathname: routeConfig.SpeakerCheckPage.path,
state: {
...location.state,
cameraCheck: { content: "", hasError: true },
},
});
}
},
);
function checkFail(): void {
history.push({
pathname: routeConfig.SpeakerCheckPage.path,
state: {
...location.state,
cameraCheck: { content: "", hasError: true },
},
});
}
});
Loading