@@ -1540,7 +1540,7 @@ fn show_previous_recordings_window(app: AppHandle) {
1540
1540
let state = app. state :: < FakeWindowBounds > ( ) ;
1541
1541
1542
1542
loop {
1543
- sleep ( Duration :: from_millis ( 1000 / 60 ) ) . await ;
1543
+ sleep ( Duration :: from_millis ( 1000 / 10 ) ) . await ;
1544
1544
1545
1545
let map = state. 0 . read ( ) . await ;
1546
1546
let Some ( windows) = map. get ( "prev-recordings" ) else {
@@ -1549,7 +1549,7 @@ fn show_previous_recordings_window(app: AppHandle) {
1549
1549
} ;
1550
1550
1551
1551
let window_position = window. outer_position ( ) . unwrap ( ) ;
1552
- let mouse_position = window. cursor_position ( ) . unwrap ( ) ; // TODO(Ilya): Panics on Windows
1552
+ let mouse_position = window. cursor_position ( ) . unwrap ( ) ;
1553
1553
let scale_factor = window. scale_factor ( ) . unwrap ( ) ;
1554
1554
1555
1555
let mut ignore = true ;
@@ -1572,6 +1572,16 @@ fn show_previous_recordings_window(app: AppHandle) {
1572
1572
}
1573
1573
1574
1574
window. set_ignore_cursor_events ( ignore) . ok ( ) ;
1575
+
1576
+ if !ignore {
1577
+ if !window. is_focused ( ) . unwrap_or ( false ) {
1578
+ window. set_focus ( ) . ok ( ) ;
1579
+ }
1580
+ } else {
1581
+ if window. is_focused ( ) . unwrap_or ( false ) {
1582
+ window. set_ignore_cursor_events ( true ) . ok ( ) ;
1583
+ }
1584
+ }
1575
1585
}
1576
1586
} ) ;
1577
1587
}
@@ -1729,6 +1739,13 @@ async fn open_settings_window(app: AppHandle, page: String) {
1729
1739
CapWindow :: Settings { page : Some ( page) } . show ( & app) ;
1730
1740
}
1731
1741
1742
+ #[ derive( Serialize , Type , tauri_specta:: Event , Debug , Clone ) ]
1743
+ pub struct UploadProgress {
1744
+ stage : String ,
1745
+ progress : f64 ,
1746
+ message : String ,
1747
+ }
1748
+
1732
1749
#[ tauri:: command]
1733
1750
#[ specta:: specta]
1734
1751
async fn upload_rendered_video (
@@ -1738,7 +1755,6 @@ async fn upload_rendered_video(
1738
1755
pre_created_video : Option < PreCreatedVideo > ,
1739
1756
) -> Result < UploadResult , String > {
1740
1757
let Ok ( Some ( mut auth) ) = AuthStore :: get ( & app) else {
1741
- // Sign out and redirect to sign in
1742
1758
AuthStore :: set ( & app, None ) . map_err ( |e| e. to_string ( ) ) ?;
1743
1759
return Ok ( UploadResult :: NotAuthenticated ) ;
1744
1760
} ;
@@ -1777,60 +1793,34 @@ async fn upload_rendered_video(
1777
1793
let editor_instance = upsert_editor_instance ( & app, video_id. clone ( ) ) . await ;
1778
1794
let mut meta = editor_instance. meta ( ) ;
1779
1795
1780
- let share_link = if let Some ( sharing) = meta. sharing {
1796
+ if let Some ( sharing) = meta. sharing {
1781
1797
notifications:: send_notification (
1782
1798
& app,
1783
1799
notifications:: NotificationType :: ShareableLinkCopied ,
1784
1800
) ;
1785
- sharing. link
1786
- } else if let Some ( pre_created) = pre_created_video {
1787
- // Use the pre-created video information
1788
- let output_path = match get_rendered_video_impl ( editor_instance. clone ( ) , project) . await {
1789
- Ok ( path) => path,
1790
- Err ( e) => return Err ( format ! ( "Failed to get rendered video: {}" , e) ) ,
1791
- } ;
1792
-
1793
- match upload_video (
1794
- & app,
1795
- video_id. clone ( ) ,
1796
- output_path,
1797
- false ,
1798
- Some ( pre_created. config ) ,
1799
- )
1800
- . await
1801
- {
1802
- Ok ( _) => {
1803
- meta. sharing = Some ( SharingMeta {
1804
- link : pre_created. link . clone ( ) ,
1805
- id : pre_created. id . clone ( ) ,
1806
- } ) ;
1807
- meta. save_for_project ( ) ;
1808
- RecordingMetaChanged { id : video_id } . emit ( & app) . ok ( ) ;
1801
+ Ok ( UploadResult :: Success ( sharing. link ) )
1802
+ } else {
1803
+ // Emit initial rendering progress
1804
+ UploadProgress {
1805
+ stage : "rendering" . to_string ( ) ,
1806
+ progress : 0.0 ,
1807
+ message : "Preparing video..." . to_string ( ) ,
1808
+ }
1809
+ . emit ( & app)
1810
+ . ok ( ) ;
1809
1811
1810
- // Don't send notification here if it was pre-created
1811
- let general_settings = GeneralSettingsStore :: get ( & app) ?;
1812
- if !general_settings
1813
- . map ( |settings| settings. auto_create_shareable_link )
1814
- . unwrap_or ( false )
1815
- {
1816
- notifications:: send_notification (
1817
- & app,
1818
- notifications:: NotificationType :: ShareableLinkCopied ,
1819
- ) ;
1812
+ let output_path = match get_rendered_video_impl ( editor_instance. clone ( ) , project) . await {
1813
+ Ok ( path) => {
1814
+ // Emit rendering complete
1815
+ UploadProgress {
1816
+ stage : "rendering" . to_string ( ) ,
1817
+ progress : 1.0 ,
1818
+ message : "Rendering complete" . to_string ( ) ,
1820
1819
}
1821
- pre_created. link
1822
- }
1823
- Err ( e) => {
1824
- notifications:: send_notification (
1825
- & app,
1826
- notifications:: NotificationType :: UploadFailed ,
1827
- ) ;
1828
- return Err ( e) ;
1820
+ . emit ( & app)
1821
+ . ok ( ) ;
1822
+ path
1829
1823
}
1830
- }
1831
- } else {
1832
- let output_path = match get_rendered_video_impl ( editor_instance. clone ( ) , project) . await {
1833
- Ok ( path) => path,
1834
1824
Err ( e) => {
1835
1825
notifications:: send_notification (
1836
1826
& app,
@@ -1840,8 +1830,34 @@ async fn upload_rendered_video(
1840
1830
}
1841
1831
} ;
1842
1832
1843
- match upload_video ( & app, video_id. clone ( ) , output_path, false , None ) . await {
1833
+ // Start upload progress
1834
+ UploadProgress {
1835
+ stage : "uploading" . to_string ( ) ,
1836
+ progress : 0.0 ,
1837
+ message : "Starting upload..." . to_string ( ) ,
1838
+ }
1839
+ . emit ( & app)
1840
+ . ok ( ) ;
1841
+
1842
+ let result = match upload_video (
1843
+ & app,
1844
+ video_id. clone ( ) ,
1845
+ output_path,
1846
+ false ,
1847
+ pre_created_video. map ( |v| v. config ) ,
1848
+ )
1849
+ . await
1850
+ {
1844
1851
Ok ( uploaded_video) => {
1852
+ // Emit upload complete
1853
+ UploadProgress {
1854
+ stage : "uploading" . to_string ( ) ,
1855
+ progress : 1.0 ,
1856
+ message : "Upload complete!" . to_string ( ) ,
1857
+ }
1858
+ . emit ( & app)
1859
+ . ok ( ) ;
1860
+
1845
1861
meta. sharing = Some ( SharingMeta {
1846
1862
link : uploaded_video. link . clone ( ) ,
1847
1863
id : uploaded_video. id . clone ( ) ,
@@ -1853,22 +1869,23 @@ async fn upload_rendered_video(
1853
1869
& app,
1854
1870
notifications:: NotificationType :: ShareableLinkCopied ,
1855
1871
) ;
1856
- uploaded_video. link
1872
+
1873
+ #[ cfg( target_os = "macos" ) ]
1874
+ platform:: write_string_to_pasteboard ( & uploaded_video. link ) ;
1875
+
1876
+ Ok ( UploadResult :: Success ( uploaded_video. link ) )
1857
1877
}
1858
1878
Err ( e) => {
1859
1879
notifications:: send_notification (
1860
1880
& app,
1861
1881
notifications:: NotificationType :: UploadFailed ,
1862
1882
) ;
1863
- return Err ( e) ;
1883
+ Err ( e)
1864
1884
}
1865
- }
1866
- } ;
1867
-
1868
- #[ cfg( target_os = "macos" ) ]
1869
- platform:: write_string_to_pasteboard ( & share_link) ;
1885
+ } ;
1870
1886
1871
- Ok ( UploadResult :: Success ( share_link) )
1887
+ result
1888
+ }
1872
1889
}
1873
1890
1874
1891
#[ tauri:: command]
@@ -2468,7 +2485,8 @@ pub async fn run() {
2468
2485
RequestOpenSettings ,
2469
2486
NewNotification ,
2470
2487
AuthenticationInvalid ,
2471
- audio_meter:: AudioInputLevelChange
2488
+ audio_meter:: AudioInputLevelChange ,
2489
+ UploadProgress ,
2472
2490
] )
2473
2491
. error_handling ( tauri_specta:: ErrorHandlingMode :: Throw )
2474
2492
. typ :: < ProjectConfiguration > ( )
0 commit comments