Skip to content

Commit

Permalink
chore(project): upgrade prettier, apply format (#2111)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious authored Jan 24, 2024
1 parent 8215c32 commit 0c222d4
Show file tree
Hide file tree
Showing 33 changed files with 561 additions and 536 deletions.
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

0 comments on commit 0c222d4

Please sign in to comment.