@@ -130,7 +130,11 @@ export class VuuDataSource extends BaseDataSource implements DataSource {
130130 const { viewport = this . viewport || ( this . viewport = uuid ( ) ) } =
131131 subscribeProps ;
132132
133- if ( this . #status === "disabled" || this . #status === "disabling" ) {
133+ if (
134+ this . #status === "disabled" ||
135+ this . #status === "disabling" ||
136+ this . #status === "enabling"
137+ ) {
134138 // We can subscribe to a disabled dataSource. No request will be
135139 // sent to server to create a new VP, just to enable the existing one.
136140 // The current subscribing client becomes the subscription owner
@@ -181,7 +185,8 @@ export class VuuDataSource extends BaseDataSource implements DataSource {
181185 } else if ( message . type === "disabled" ) {
182186 this . #status = "disabled" ;
183187 } else if ( message . type === "enabled" ) {
184- this . #status = "enabled" ;
188+ this . #status = "subscribed" ;
189+ this . emit ( "enabled" , this . viewport ) ;
185190 } else if ( isDataSourceConfigMessage ( message ) ) {
186191 // This is an ACK for a CHANGE_VP message. Nothing to do here. We need
187192 // to wait for data to be returned before we can consider the change
@@ -248,6 +253,9 @@ export class VuuDataSource extends BaseDataSource implements DataSource {
248253 escalateToDisable = this . _defaultSuspenseProps . escalateToDisable ,
249254 escalateDelay = this . _defaultSuspenseProps . escalateDelay ,
250255 ) {
256+ console . log (
257+ `[VuuDataSuurce] suspend, current status ${ this . #status} , escalateToDisable ? ${ escalateToDisable } ` ,
258+ ) ;
251259 if ( this . #status !== "unsubscribed" ) {
252260 info ?.( `suspend #${ this . viewport } , current status ${ this . #status} ` ) ;
253261 if ( this . viewport ) {
@@ -264,6 +272,7 @@ export class VuuDataSource extends BaseDataSource implements DataSource {
264272 }
265273
266274 resume ( callback ?: DataSourceSubscribeCallback ) {
275+ console . log ( `[VuuDataSuurce] resume, current status ${ this . #status} ` ) ;
267276 const isDisabled = this . #status. startsWith ( "disabl" ) ;
268277 const isSuspended = this . #status === "suspended" ;
269278 info ?.( `resume #${ this . viewport } , current status ${ this . #status} ` ) ;
@@ -334,6 +343,7 @@ export class VuuDataSource extends BaseDataSource implements DataSource {
334343 viewport : this . viewport ,
335344 type : "enable" ,
336345 } ) ;
346+ // TODO is this a bit premature ?
337347 this . emit ( "enabled" , this . viewport ) ;
338348 }
339349 }
0 commit comments