mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-27 00:05:39 +00:00
Address HUD protection review feedback
This commit is contained in:
@@ -19,6 +19,7 @@ import { useScopedT } from "../../contexts/I18nContext";
|
||||
import { useMicrophoneDevices } from "../../hooks/useMicrophoneDevices";
|
||||
import { useScreenRecorder } from "../../hooks/useScreenRecorder";
|
||||
import { useVideoDevices } from "../../hooks/useVideoDevices";
|
||||
import { supportsHudCaptureProtection } from "../../lib/hudCaptureProtection";
|
||||
import { Button } from "../ui/button";
|
||||
import { HudInteractionContext } from "./contexts/HudInteractionContext";
|
||||
import { canToggleFloatingWebcamPreview } from "./floatingWebcamPreview";
|
||||
@@ -115,7 +116,7 @@ function LaunchWindowContent() {
|
||||
toggleHudCaptureProtection,
|
||||
} = useLaunchWindowSystemState(preparePermissions);
|
||||
|
||||
const supportsHudCaptureProtection = true;
|
||||
const hudCaptureProtectionSupported = supportsHudCaptureProtection(platform ?? "");
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedDeviceId) {
|
||||
@@ -372,7 +373,7 @@ function LaunchWindowContent() {
|
||||
</div>
|
||||
|
||||
<MorePopover
|
||||
supportsHudCaptureProtection={supportsHudCaptureProtection}
|
||||
supportsHudCaptureProtection={hudCaptureProtectionSupported}
|
||||
hideHudFromCapture={hideHudFromCapture}
|
||||
onToggleHudCaptureProtection={() => {
|
||||
void toggleHudCaptureProtection();
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
getHudCaptureExcludedProcessIds,
|
||||
supportsHudCaptureProtection,
|
||||
} from "./hudCaptureProtection";
|
||||
|
||||
describe("supportsHudCaptureProtection", () => {
|
||||
it.each([
|
||||
["win32", true],
|
||||
["darwin", true],
|
||||
["linux", false],
|
||||
["freebsd", false],
|
||||
])("reports support for %s as %s", (platform, expected) => {
|
||||
expect(supportsHudCaptureProtection(platform)).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getHudCaptureExcludedProcessIds", () => {
|
||||
it("passes the current process to macOS capture when protection is enabled", () => {
|
||||
expect(getHudCaptureExcludedProcessIds("darwin", true, 4512)).toEqual([4512]);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["darwin", false, 4512],
|
||||
["win32", true, 4512],
|
||||
["linux", true, 4512],
|
||||
["darwin", true, 0],
|
||||
["darwin", true, Number.NaN],
|
||||
])("returns no native exclusions for %s, enabled=%s, pid=%s", (platform, enabled, pid) => {
|
||||
expect(getHudCaptureExcludedProcessIds(platform, enabled, pid as number)).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
export function supportsHudCaptureProtection(platform: string): boolean {
|
||||
return platform === "darwin" || platform === "win32";
|
||||
}
|
||||
|
||||
export function getHudCaptureExcludedProcessIds(
|
||||
platform: string,
|
||||
enabled: boolean,
|
||||
processId: number,
|
||||
): number[] {
|
||||
if (platform !== "darwin" || !enabled || !Number.isSafeInteger(processId) || processId <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [processId];
|
||||
}
|
||||
Reference in New Issue
Block a user