File tree Expand file tree Collapse file tree
build/devices/pebble/modules/global Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,31 +51,31 @@ export class Pebble {
5151 if ( index < 0 )
5252 return ;
5353
54- if ( ! this . #events. has ( event ) )
55- this . #events. set ( event , [ callback ] ) ;
56- else
57- this . #events. get ( event ) . push ( callback ) ;
58-
59- if ( index <= 3 ) {
60- // immediate for first one
61- Timer . set ( ( ) => {
62- callback ( { date : new Date } ) ;
63- } ) ;
64-
65- this . #schedule( ) ;
66- return ;
67- }
54+ const e = this . #events. getOrInsert ( event , [ ] ) ;
6855
69- switch ( event ) {
70- case "connected" :
71- if ( 1 === this . #events . get ( event ) . length )
56+ switch ( index ) {
57+ case 4 : // "connected":
58+ if ( ! e . length )
7259 connected ( true ) ;
7360 break ;
74- case "resize" :
75- if ( 1 === this . #events. get ( event ) . length )
76- obstructed ( true ) ;
61+
62+ case 5 : // "resize":
63+ if ( ! e . length && ! obstructed ( true ) )
64+ return ; // app doesn't support obstruct notification (not a watchface)
7765 break ;
66+
67+ default :
68+ // always invoke time callback immediately
69+ Timer . set ( ( ) => {
70+ callback ( { date : new Date } ) ;
71+ } ) ;
72+
73+ this . #schedule( ) ;
74+ break ;
75+
7876 }
77+
78+ e . push ( callback )
7979 }
8080 #schedule( ) {
8181 const seconds = this . #events. has ( "secondchange" ) , minutes = this . #events. has ( "minutechange" ) ,
Original file line number Diff line number Diff line change 2323#include "mc.xs.h" // for xsID_ values
2424#include "moddableAppState.h"
2525#include "services/common/clock.h"
26+ #include "applib/app_watch_info.h"
2627#include "applib/connection_service.h"
2728#include "process_state/app_state/app_state.h"
2829
@@ -82,8 +83,12 @@ static const UnobstructedAreaHandlers gUnobstructedHandlers = {
8283
8384void xs_global_obstructed (xsMachine * the )
8485{
85- if (xsmcTest (xsArg (0 )))
86- app_unobstructed_area_service_subscribe (gUnobstructedHandlers , the );
86+ if (xsmcTest (xsArg (0 ))) {
87+ if (app_manager_is_watchface_running ()) {
88+ app_unobstructed_area_service_subscribe (gUnobstructedHandlers , the );
89+ xsmcSetTrue (xsResult );
90+ }
91+ }
8792 else
8893 app_unobstructed_area_service_unsubscribe ();
8994}
You can’t perform that action at this time.
0 commit comments