File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -574,8 +574,11 @@ LocalQueue.prototype.queue = function( change ) {
574574 if ( ! this . ready ) return ;
575575
576576 this . processQueue ( change . id ) ;
577- }
578- ;
577+ } ;
578+
579+ LocalQueue . prototype . hasChanges = function ( ) {
580+ return Object . keys ( this . queues ) . length > 0 ;
581+ } ;
579582
580583LocalQueue . prototype . dequeueChangesFor = function ( id ) {
581584 var changes = [ ] , sent = this . sent [ id ] , queue = this . queues [ id ] ;
Original file line number Diff line number Diff line change @@ -71,6 +71,10 @@ Client.prototype.bucket = function( name ) {
7171
7272 if ( this . open ) channel . onConnect ( ) ;
7373
74+ bucket . hasLocalChanges = function ( ) {
75+ return channel . localQueue . hasChanges ( ) ;
76+ } ;
77+
7478 return bucket ;
7579} ;
7680
Original file line number Diff line number Diff line change @@ -310,6 +310,29 @@ describe( 'Channel', function() {
310310 } ) ;
311311 } ) ;
312312
313+ it ( 'should have local changes on send' , function ( done ) {
314+ channel . once ( 'send' , function ( ) {
315+ assert . equal ( channel . localQueue . hasChanges ( ) , true ) ;
316+ done ( ) ;
317+ } ) ;
318+
319+ store . put ( '123' , 3 , { title : 'hello world' } ) . then ( function ( ) {
320+ bucket . update ( '123' , { title : 'goodbye world!!' } ) ;
321+ } ) ;
322+ } ) ;
323+
324+ it ( 'should have no local changes after ack' , function ( done ) {
325+ channel . on ( 'acknowledge' , function ( ) {
326+ assert . equal ( channel . localQueue . hasChanges ( ) , false ) ;
327+ done ( ) ;
328+ } ) ;
329+
330+ store . put ( '123' , 3 , { title : 'hello world' } ) . then ( function ( ) {
331+ bucket . update ( '123' , { title : 'goodbye world!!' } ) ;
332+ done ( ) ;
333+ } ) ;
334+ } ) ;
335+
313336 // If receiving a remote change while there are unsent local modifications,
314337 // local changes should be rebased onto the new ghost and re-sent
315338 it ( 'should resolve applying patch to modified object' , function ( done ) {
You can’t perform that action at this time.
0 commit comments