File tree Expand file tree Collapse file tree
client/src/features/stream Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ function currentClientBundle(): string {
100100}
101101
102102function isDocumentForeground ( ) : boolean {
103- return document . visibilityState === "visible" && document . hasFocus ( ) ;
103+ return document . visibilityState === "visible" ;
104104}
105105
106106export function useLiveStream ( {
@@ -371,17 +371,13 @@ export function useLiveStream({
371371
372372 sendCurrentForegroundState ( ) ;
373373 document . addEventListener ( "visibilitychange" , sendCurrentForegroundState ) ;
374- window . addEventListener ( "focus" , sendCurrentForegroundState ) ;
375- window . addEventListener ( "blur" , sendCurrentForegroundState ) ;
376374 window . addEventListener ( "pageshow" , sendCurrentForegroundState ) ;
377375 window . addEventListener ( "pagehide" , sendBackgroundState ) ;
378376 return ( ) => {
379377 document . removeEventListener (
380378 "visibilitychange" ,
381379 sendCurrentForegroundState ,
382380 ) ;
383- window . removeEventListener ( "focus" , sendCurrentForegroundState ) ;
384- window . removeEventListener ( "blur" , sendCurrentForegroundState ) ;
385381 window . removeEventListener ( "pageshow" , sendCurrentForegroundState ) ;
386382 window . removeEventListener ( "pagehide" , sendBackgroundState ) ;
387383 } ;
Original file line number Diff line number Diff line change @@ -1408,9 +1408,7 @@ fn client_stats_foreground(stats: &ClientStreamStats) -> Option<bool> {
14081408 if stats. kind != "page" {
14091409 return None ;
14101410 }
1411- let visible = stats. visibility_state . as_deref ( ) == Some ( "visible" ) ;
1412- let focused = stats. focused ?;
1413- Some ( visible && focused)
1411+ Some ( stats. visibility_state . as_deref ( ) ? == "visible" )
14141412}
14151413
14161414async fn native_inspector_connect (
@@ -6141,7 +6139,7 @@ mod tests {
61416139 }
61426140
61436141 #[ test]
6144- fn client_stats_foreground_requires_visible_and_focused_page ( ) {
6142+ fn client_stats_foreground_uses_page_visibility ( ) {
61456143 let page_stats =
61466144 |visibility_state : Option < & str > , focused : Option < bool > | ClientStreamStats {
61476145 client_id : "client" . to_owned ( ) ,
@@ -6157,14 +6155,18 @@ mod tests {
61576155 ) ;
61586156 assert_eq ! (
61596157 client_stats_foreground( & page_stats( Some ( "visible" ) , Some ( false ) ) ) ,
6160- Some ( false )
6158+ Some ( true )
61616159 ) ;
61626160 assert_eq ! (
61636161 client_stats_foreground( & page_stats( Some ( "hidden" ) , Some ( true ) ) ) ,
61646162 Some ( false )
61656163 ) ;
61666164 assert_eq ! (
61676165 client_stats_foreground( & page_stats( Some ( "visible" ) , None ) ) ,
6166+ Some ( true )
6167+ ) ;
6168+ assert_eq ! (
6169+ client_stats_foreground( & page_stats( None , Some ( true ) ) ) ,
61686170 None
61696171 ) ;
61706172 assert_eq ! (
You can’t perform that action at this time.
0 commit comments