Skip to content

Commit ebf3714

Browse files
wip
1 parent 1c2dac2 commit ebf3714

8 files changed

Lines changed: 37 additions & 26 deletions

File tree

apps/desktop/src-tauri/src/api.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ use serde::{Deserialize, Serialize};
55
use serde_json::json;
66
use tauri::AppHandle;
77

8-
use crate::web_api::ManagerExt;
8+
use crate::web_api::{AuthedApiError, ManagerExt};
99

10-
pub async fn upload_multipart_initiate(app: &AppHandle, video_id: &str) -> Result<String, String> {
10+
pub async fn upload_multipart_initiate(
11+
app: &AppHandle,
12+
video_id: &str,
13+
) -> Result<String, AuthedApiError> {
1114
#[derive(Deserialize)]
1215
#[serde(rename_all = "camelCase")]
1316
pub struct Response {
@@ -49,7 +52,7 @@ pub async fn upload_multipart_presign_part(
4952
upload_id: &str,
5053
part_number: u32,
5154
md5_sum: &str,
52-
) -> Result<String, String> {
55+
) -> Result<String, AuthedApiError> {
5356
#[derive(Deserialize)]
5457
#[serde(rename_all = "camelCase")]
5558
pub struct Response {
@@ -114,7 +117,7 @@ pub async fn upload_multipart_complete(
114117
upload_id: &str,
115118
parts: &[UploadedPart],
116119
meta: Option<S3VideoMeta>,
117-
) -> Result<Option<String>, String> {
120+
) -> Result<Option<String>, AuthedApiError> {
118121
#[derive(Serialize)]
119122
#[serde(rename_all = "camelCase")]
120123
pub struct MultipartCompleteRequest<'a> {
@@ -179,7 +182,10 @@ pub struct PresignedS3PutRequest {
179182
pub meta: Option<S3VideoMeta>,
180183
}
181184

182-
pub async fn upload_signed(app: &AppHandle, body: PresignedS3PutRequest) -> Result<String, String> {
185+
pub async fn upload_signed(
186+
app: &AppHandle,
187+
body: PresignedS3PutRequest,
188+
) -> Result<String, AuthedApiError> {
183189
#[derive(Deserialize)]
184190
struct Data {
185191
url: String,
@@ -218,7 +224,7 @@ pub async fn desktop_video_progress(
218224
video_id: &str,
219225
uploaded: u64,
220226
total: u64,
221-
) -> Result<(), String> {
227+
) -> Result<(), AuthedApiError> {
222228
let resp = app
223229
.authed_api_request("/api/desktop/video/progress", |client, url| {
224230
client.post(url).json(&json!({

apps/desktop/src-tauri/src/auth.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,3 @@ impl AuthStore {
118118
store.save().map_err(|e| e.to_string())
119119
}
120120
}
121-
122-
#[derive(specta::Type, serde::Serialize, tauri_specta::Event, Debug, Clone, serde::Deserialize)]
123-
pub struct AuthenticationInvalid;

apps/desktop/src-tauri/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mod web_api;
2828
mod windows;
2929

3030
use audio::AppSounds;
31-
use auth::{AuthStore, AuthenticationInvalid, Plan};
31+
use auth::{AuthStore, Plan};
3232
use camera::CameraPreviewState;
3333
use cap_editor::{EditorInstance, EditorState};
3434
use cap_project::{
@@ -2000,7 +2000,6 @@ pub async fn run(recording_logging_handle: LoggingHandle) {
20002000
RequestOpenSettings,
20012001
RequestScreenCapturePrewarm,
20022002
NewNotification,
2003-
AuthenticationInvalid,
20042003
audio_meter::AudioInputLevelChange,
20052004
captions::DownloadProgress,
20062005
recording::RecordingEvent,

apps/desktop/src-tauri/src/recording.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use tauri_plugin_dialog::{DialogExt, MessageDialogBuilder};
3737
use tauri_specta::Event;
3838
use tracing::*;
3939

40+
use crate::web_api::AuthedApiError;
4041
use crate::{
4142
App, CurrentRecordingChanged, MutableState, NewStudioRecordingAdded, RecordingState,
4243
RecordingStopped, VideoUploadInfo,
@@ -252,7 +253,7 @@ pub async fn start_recording(
252253
app: AppHandle,
253254
state_mtx: MutableState<'_, App>,
254255
inputs: StartRecordingInputs,
255-
) -> Result<(), String> {
256+
) -> Result<(), AuthedApiError> {
256257
if !matches!(state_mtx.read().await.recording_state, RecordingState::None) {
257258
return Err("Recording already in progress".to_string());
258259
}

apps/desktop/src-tauri/src/upload.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ pub async fn upload_video(
8787
id: v.id,
8888
});
8989
}
90-
>>>>>>> main
9190

9291
info!("Uploading video {video_id}...");
9392

apps/desktop/src-tauri/src/web_api.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use tracing::{error, warn};
66

77
use crate::{
88
ArcLock,
9-
auth::{AuthSecret, AuthStore, AuthenticationInvalid},
9+
auth::{AuthSecret, AuthStore},
1010
};
1111

1212
#[derive(Error, Debug)]
@@ -83,7 +83,6 @@ impl<T: Manager<R> + Emitter<R>, R: Runtime> ManagerExt<R> for T {
8383
let Some(auth) = AuthStore::get(self.app_handle()).map_err(AuthedApiError::AuthStore)?
8484
else {
8585
warn!("Not logged in");
86-
AuthenticationInvalid.emit(self).ok();
8786
return Err(AuthedApiError::InvalidAuthentication);
8887
};
8988

@@ -92,7 +91,6 @@ impl<T: Manager<R> + Emitter<R>, R: Runtime> ManagerExt<R> for T {
9291

9392
if response.status() == StatusCode::UNAUTHORIZED {
9493
error!("Authentication expired. Please log in again.");
95-
AuthenticationInvalid.emit(self).ok();
9694
return Err(AuthedApiError::InvalidAuthentication);
9795
}
9896

apps/desktop/src/routes/(window-chrome)/(main).tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,16 @@ function Page() {
238238
}
239239
})();
240240

241-
await commands.startRecording({
242-
capture_target,
243-
mode: payload.mode,
244-
capture_system_audio: rawOptions.captureSystemAudio,
245-
});
241+
try {
242+
await commands.startRecording({
243+
capture_target,
244+
mode: payload.mode,
245+
capture_system_audio: rawOptions.captureSystemAudio,
246+
});
247+
} catch (err) {
248+
alert("CRINGE");
249+
throw err;
250+
}
246251
} else await commands.stopRecording();
247252
},
248253
}));

apps/desktop/src/routes/target-select-overlay.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -811,11 +811,17 @@ function RecordingControls(props: {
811811
return;
812812
}
813813

814-
commands.startRecording({
815-
capture_target: props.target,
816-
mode: rawOptions.mode,
817-
capture_system_audio: rawOptions.captureSystemAudio,
818-
});
814+
commands
815+
.startRecording({
816+
capture_target: props.target,
817+
mode: rawOptions.mode,
818+
capture_system_audio: rawOptions.captureSystemAudio,
819+
})
820+
.catch((err) => {
821+
console.log(err);
822+
alert("CRINGE");
823+
throw err;
824+
});
819825
}}
820826
>
821827
<div class="flex items-center py-1 pl-4 transition-colors hover:bg-blue-10">

0 commit comments

Comments
 (0)