feat(macos): Added asynchronous microphone permisson request#187
feat(macos): Added asynchronous microphone permisson request#187Lynden-Sylvester wants to merge 1 commit intostoatchat:mainfrom
Conversation
Signed-off-by: Lynden-Sylvester <78802283+Lynden-Sylvester@users.noreply.github.com>
| // -- macOS Microphone Permission -- | ||
| try { | ||
| const granted = await systemPreferences.askForMediaAccess("microphone"); | ||
| console.log("Microphone access granted:", granted); | ||
| } catch (error) { | ||
| console.error("Error requesting microphone access:", error); | ||
| } | ||
| // ----------------------------------- |
There was a problem hiding this comment.
I'm not on the frontend team but this should certainly not be happening on app startup. Permissions should only be requested as-needed, eg when the user attempts to join a voice chat.
There was a problem hiding this comment.
I agree.
I wasn't super sure which repo it belonged to because it is a desktop-specific feature for macOS, but the for-desktop repo is just a wrapper of the for-web repo where the voice rooms are, and it's not clear what the entry point is that triggers the process of joining a room, as that should trigger a check to see if Stoat has the microphone permission granted, and if not, to trigger the call to the System Preferences to request that permission and await the response to receive granted or denied status. And have the Key-pair for the permission added to the plist, which to my understanding is generated by forge here in the for-desktop repo.
I'd love to implement the feature in the way that best works with the codebase, and if someone from the frontend team can point me in the right direction, that'd be great! As from a contributor's perspective, it looks like one part needs to be added in one repo and the other part in another. So it's a little confusing.
There was a problem hiding this comment.
Switching this to a draft, and will wait for someone from the frontend team to let me know the the right repository and file to look at to move the permission addition to.
This feature addition addresses this issue stated here: #102, and removes the need for the manual fix #102 (comment) by handling it in the code itself, baking the process so future users don't have to manually add the permission request in their Terminal.
Changes Made
forge.config.ts- Added Microphone usage description topackagerConfig:src/main.ts- Updated imports and ready handler:app.on("ready", () => {}toapp.on("ready", async () => {}await systemPreferences.askForMediaAccess("microphone");with error handlingTesting