Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Refresh prev-recordings panel on render

Richie McIlroyf81da81b70f2
diff --git a/apps/desktop-solid/src-tauri/src/lib.rs b/apps/desktop-solid/src-tauri/src/lib.rs
index c38bd794f..6ec5973fb 100644
--- a/apps/desktop-solid/src-tauri/src/lib.rs
+++ b/apps/desktop-solid/src-tauri/src/lib.rs
@@ -157,6 +157,10 @@ pub struct RecordingOptionsChanged;
#[derive(specta::Type, Serialize, tauri_specta::Event, Clone)]
pub struct ShowCapturesPanel;
+// dedicated event + command used as panel must be accessed on main thread
+#[derive(specta::Type, Serialize, tauri_specta::Event, Clone)]
+pub struct RefreshCapturesPanel;
+
type MutableState<'a, T> = State<'a, Arc<RwLock<T>>>;
#[tauri::command]
@@ -927,7 +931,7 @@ async fn render_to_file(
.await
.ok();
- ShowCapturesPanel.emit(&app).ok();
+ RefreshCapturesPanel.emit(&app).ok();
}
#[tauri::command]
@@ -992,6 +996,7 @@ pub fn run() {
.events(tauri_specta::collect_events![
RecordingOptionsChanged,
ShowCapturesPanel,
+ RefreshCapturesPanel,
RenderFrameEvent,
EditorStateChanged
])
diff --git a/apps/desktop-solid/src/routes/prev-recordings.tsx b/apps/desktop-solid/src/routes/prev-recordings.tsx
index bf62ad098..9f077301d 100644
--- a/apps/desktop-solid/src/routes/prev-recordings.tsx
+++ b/apps/desktop-solid/src/routes/prev-recordings.tsx
@@ -32,6 +32,10 @@ export default function () {
recordings.refetch();
});
+ events.refreshCapturesPanel.listen(() => {
+ location.reload();
+ });
+
const [removedCount, setRemovedCount] = createSignal(0);
const [hasClosedWindow, setHasClosedWindow] = createSignal(false);
const [isScrolledToTop, setIsScrolledToTop] = createSignal(true);
diff --git a/apps/desktop-solid/src/utils/tauri.ts b/apps/desktop-solid/src/utils/tauri.ts
index f0ee099ef..1b94a6e8b 100644
--- a/apps/desktop-solid/src/utils/tauri.ts
+++ b/apps/desktop-solid/src/utils/tauri.ts
@@ -145,11 +145,13 @@ async openInFinder(path: string) : Promise<void> {
export const events = __makeEvents__<{
editorStateChanged: EditorStateChanged,
recordingOptionsChanged: RecordingOptionsChanged,
+refreshCapturesPanel: RefreshCapturesPanel,
renderFrameEvent: RenderFrameEvent,
showCapturesPanel: ShowCapturesPanel
}>({
editorStateChanged: "editor-state-changed",
recordingOptionsChanged: "recording-options-changed",
+refreshCapturesPanel: "refresh-captures-panel",
renderFrameEvent: "render-frame-event",
showCapturesPanel: "show-captures-panel"
})
@@ -181,6 +183,7 @@ export type JsonValue<T> = [T]
export type ProjectConfiguration = { aspectRatio: AspectRatio | null; background: BackgroundConfiguration; camera: CameraConfiguration; audio: AudioConfiguration; cursor: CursorConfiguration; hotkeys: HotkeysConfiguration }
export type RecordingOptions = { captureTarget: CaptureTarget; cameraLabel: string | null; audioInputName: string | null }
export type RecordingOptionsChanged = null
+export type RefreshCapturesPanel = null
export type RenderFrameEvent = { frame_number: number; project: ProjectConfiguration }
export type RenderProgress = { type: "Starting"; total_frames: number } | { type: "EstimatedTotalFrames"; total_frames: number } | { type: "FrameRendered"; current_frame: number }
export type ShowCapturesPanel = null