Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Add JS device enumeration

Richie McIlroy3c1ca8a5d650
diff --git a/Cargo.lock b/Cargo.lock
index 18591e0cf..7975ef031 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1400,7 +1400,7 @@ dependencies = [
[[package]]
name = "desktop"
-version = "0.3.0-alpha.1"
+version = "0.3.0-alpha.4"
dependencies = [
"anyhow",
"axum",
diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml
index 3efd69a1a..92ff38afb 100644
--- a/apps/desktop/src-tauri/Cargo.toml
+++ b/apps/desktop/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "desktop"
-version = "0.3.0-alpha.1"
+version = "0.3.0-alpha.4"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
diff --git a/apps/desktop/src/routes/permissions.tsx b/apps/desktop/src/routes/permissions.tsx
index c93e982e1..3e262e90b 100644
--- a/apps/desktop/src/routes/permissions.tsx
+++ b/apps/desktop/src/routes/permissions.tsx
@@ -23,16 +23,32 @@ export default function () {
const [currentStep, setCurrentStep] = createSignal(0);
- const permissionsGranted = () => {
+ const permissionsGranted = async () => {
const c = check.latest;
if (c?.os === "macOS") {
- return c?.screenRecording && c?.camera && c?.microphone;
+ const hasScreenRecording = c?.screenRecording;
+ let hasCamera = c?.camera;
+ let hasMicrophone = c?.microphone;
+
+ if (!hasCamera || !hasMicrophone) {
+ try {
+ const devices = await navigator.mediaDevices.enumerateDevices();
+ hasCamera = devices.some((device) => device.kind === "videoinput");
+ hasMicrophone = devices.some(
+ (device) => device.kind === "audioinput"
+ );
+ } catch (error) {
+ console.error("Error enumerating devices:", error);
+ }
+ }
+
+ return hasScreenRecording && hasCamera && hasMicrophone;
}
return false;
};
- createEffect(() => {
- if (permissionsGranted()) {
+ createEffect(async () => {
+ if (await permissionsGranted()) {
commands.openMainWindow();
const window = getCurrentWindow();
window.close();