-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(deeplink): add pause, resume, and device switching actions (#1540) #1549
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,6 +32,14 @@ pub enum DeepLinkAction { | |||||||||||||||||||||||||||||||||||||||||||||
| OpenSettings { | ||||||||||||||||||||||||||||||||||||||||||||||
| page: Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| PauseRecording, | ||||||||||||||||||||||||||||||||||||||||||||||
| ResumeRecording, | ||||||||||||||||||||||||||||||||||||||||||||||
| SwitchMicrophone { | ||||||||||||||||||||||||||||||||||||||||||||||
| mic_label: Option<String>, | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| SwitchCamera { | ||||||||||||||||||||||||||||||||||||||||||||||
| camera: Option<DeviceOrModelID>, | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| pub fn handle(app_handle: &AppHandle, urls: Vec<Url>) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -152,6 +160,41 @@ impl DeepLinkAction { | |||||||||||||||||||||||||||||||||||||||||||||
| DeepLinkAction::OpenSettings { page } => { | ||||||||||||||||||||||||||||||||||||||||||||||
| crate::show_window(app.clone(), ShowCapWindow::Settings { page }).await | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| DeepLinkAction::PauseRecording => { | ||||||||||||||||||||||||||||||||||||||||||||||
| crate::recording::pause_recording(app.clone(), app.state()).await | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
163
to
165
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Holding the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| DeepLinkAction::ResumeRecording => { | ||||||||||||||||||||||||||||||||||||||||||||||
| crate::recording::resume_recording(app.clone(), app.state()).await | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
166
to
168
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same idea here: drop the read lock before awaiting
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| DeepLinkAction::SwitchMicrophone { mic_label } => { | ||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(ref label) = mic_label { | ||||||||||||||||||||||||||||||||||||||||||||||
| let available_mics = cap_recording::feeds::microphone::MicrophoneFeed::list(); | ||||||||||||||||||||||||||||||||||||||||||||||
| if !available_mics.contains_key(label) { | ||||||||||||||||||||||||||||||||||||||||||||||
| return Err(format!("Microphone with label \"{}\" not found", label)); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| let state = app.state::<ArcLock<App>>(); | ||||||||||||||||||||||||||||||||||||||||||||||
| crate::set_mic_input(state, mic_label).await | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| DeepLinkAction::SwitchCamera { camera } => { | ||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(ref id) = camera { | ||||||||||||||||||||||||||||||||||||||||||||||
| let cameras: Vec<_> = cap_camera::list_cameras().collect(); | ||||||||||||||||||||||||||||||||||||||||||||||
| let exists = cameras.iter().any(|info| match id { | ||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor thing: you can avoid allocating
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| DeviceOrModelID::DeviceID(device_id) => info.device_id() == device_id, | ||||||||||||||||||||||||||||||||||||||||||||||
| DeviceOrModelID::ModelID(model_id) => { | ||||||||||||||||||||||||||||||||||||||||||||||
| info.model_id().is_some_and(|existing| existing == model_id) | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if !exists { | ||||||||||||||||||||||||||||||||||||||||||||||
| return Err(format!("Camera with ID \"{:?}\" not found", id)); | ||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor UX:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| let state = app.state::<ArcLock<App>>(); | ||||||||||||||||||||||||||||||||||||||||||||||
| crate::set_camera_input(app.clone(), state, camera).await | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
SwitchMicrophone/SwitchCamera, usingOptionmeans a missing/nullfield in the deeplink will remove the device. If that’s not intended, consider making these fields required or treatingNoneas a no-op/error to avoid accidental device disable.