Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix watermark auth check

Brendan Allan3adba16abb8e
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index e56067c11..9b3d41d47 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -873,7 +873,15 @@ impl EditorStateChanged {
async fn start_playback(app: AppHandle, video_id: String, fps: u32, resolution_base: XY<u32>) {
upsert_editor_instance(&app, video_id)
.await
- .start_playback(fps, resolution_base)
+ .start_playback(
+ fps,
+ resolution_base,
+ AuthStore::get(&app)
+ .ok()
+ .flatten()
+ .map(|s| s.is_upgraded())
+ .unwrap_or(false),
+ )
.await
}
@@ -2335,15 +2343,31 @@ pub async fn upsert_editor_instance(app: &AppHandle, video_id: String) -> Arc<Ed
}
async fn create_editor_instance_impl(app: &AppHandle, video_id: String) -> Arc<EditorInstance> {
- let instance = EditorInstance::new(recordings_path(app), video_id, {
- let app = app.clone();
- move |state| {
- EditorStateChanged::new(state).emit(&app).ok();
- }
- })
+ let app = app.clone();
+
+ let instance = EditorInstance::new(
+ recordings_path(&app),
+ video_id,
+ {
+ let app = app.clone();
+ move |state| {
+ EditorStateChanged::new(state).emit(&app).ok();
+ }
+ },
+ {
+ let app = app.clone();
+ move || {
+ AuthStore::get(&app)
+ .ok()
+ .flatten()
+ .map(|s| s.is_upgraded())
+ .unwrap_or(false)
+ }
+ },
+ )
.await;
- RenderFrameEvent::listen_any(app, {
+ RenderFrameEvent::listen_any(&app, {
let preview_tx = instance.preview_tx.clone();
move |e| {
preview_tx
diff --git a/crates/editor/src/editor_instance.rs b/crates/editor/src/editor_instance.rs
index 8eae9f51a..7956446ba 100644
--- a/crates/editor/src/editor_instance.rs
+++ b/crates/editor/src/editor_instance.rs
@@ -40,6 +40,7 @@ impl EditorInstance {
projects_path: PathBuf,
video_id: String,
on_state_change: impl Fn(&EditorState) + Send + Sync + 'static,
+ get_is_upgraded: impl Fn() -> bool + Send + 'static,
) -> Arc<Self> {
sentry::configure_scope(|scope| {
scope.set_tag("crate", "editor");
@@ -115,8 +116,10 @@ impl EditorInstance {
meta,
});
- this.state.lock().await.preview_task =
- Some(this.clone().spawn_preview_renderer(preview_rx));
+ this.state.lock().await.preview_task = Some(
+ this.clone()
+ .spawn_preview_renderer(preview_rx, get_is_upgraded),
+ );
this
}
@@ -173,7 +176,12 @@ impl EditorInstance {
(self.on_state_change)(&state);
}
- pub async fn start_playback(self: Arc<Self>, fps: u32, resolution_base: XY<u32>) {
+ pub async fn start_playback(
+ self: Arc<Self>,
+ fps: u32,
+ resolution_base: XY<u32>,
+ is_upgraded: bool,
+ ) {
let (mut handle, prev) = {
let Ok(mut state) = self.state.try_lock() else {
return;
@@ -188,7 +196,7 @@ impl EditorInstance {
start_frame_number,
project: self.project_config.0.subscribe(),
}
- .start(fps, resolution_base)
+ .start(fps, resolution_base, is_upgraded)
.await;
let prev = state.playback_task.replace(playback_handle.clone());
@@ -224,6 +232,7 @@ impl EditorInstance {
fn spawn_preview_renderer(
self: Arc<Self>,
mut preview_rx: watch::Receiver<Option<(u32, u32, XY<u32>)>>,
+ get_is_upgraded: impl Fn() -> bool + Send + 'static,
) -> tokio::task::JoinHandle<()> {
tokio::spawn(async move {
loop {
@@ -261,7 +270,7 @@ impl EditorInstance {
&project,
time as f32,
resolution_base,
- false,
+ get_is_upgraded(),
),
time as f32,
resolution_base,
diff --git a/crates/editor/src/playback.rs b/crates/editor/src/playback.rs
index 809bb282c..5ecb10650 100644
--- a/crates/editor/src/playback.rs
+++ b/crates/editor/src/playback.rs
@@ -35,7 +35,12 @@ pub struct PlaybackHandle {
}
impl Playback {
- pub async fn start(self, fps: u32, resolution_base: XY<u32>) -> PlaybackHandle {
+ pub async fn start(
+ self,
+ fps: u32,
+ resolution_base: XY<u32>,
+ is_upgraded: bool,
+ ) -> PlaybackHandle {
let (stop_tx, mut stop_rx) = watch::channel(false);
stop_rx.borrow_and_update();
@@ -101,7 +106,7 @@ impl Playback {
&project,
time as f32,
resolution_base,
- false,
+ is_upgraded,
);
self