File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ describe('Cursors', () => {
116116 vi . spyOn ( channel . presence , 'get' ) . mockImplementation ( createPresenceCount ( 2 ) ) ;
117117 await cursors [ 'onPresenceUpdate' ] ( ) ;
118118 expect ( batching . shouldSend ) . toBeTruthy ( ) ;
119- expect ( batching . batchTime ) . toEqual ( 50 ) ;
119+ expect ( batching . batchTime ) . toEqual ( 25 ) ;
120120 } ) ;
121121
122122 it < CursorsTestContext > ( 'batchTime is updated when multiple people are present' , async ( {
@@ -126,7 +126,7 @@ describe('Cursors', () => {
126126 } ) => {
127127 vi . spyOn ( channel . presence , 'get' ) . mockImplementation ( createPresenceCount ( 2 ) ) ;
128128 await cursors [ 'onPresenceUpdate' ] ( ) ;
129- expect ( batching . batchTime ) . toEqual ( 50 ) ;
129+ expect ( batching . batchTime ) . toEqual ( 25 ) ;
130130 } ) ;
131131
132132 describe ( 'pushCursorPosition' , ( ) => {
Original file line number Diff line number Diff line change @@ -105,7 +105,11 @@ export default class Cursors extends EventEmitter<CursorsEventMap> {
105105 const channel = this . getChannel ( ) ;
106106 const cursorsMembers = await channel . presence . get ( ) ;
107107 this . cursorBatching . setShouldSend ( cursorsMembers . length > 1 ) ;
108- this . cursorBatching . setBatchTime ( cursorsMembers . length * this . options . outboundBatchInterval ) ;
108+ /**
109+ * Since server-side batching is automically enabled for cursors channels, we can now adjust the client-side batching interval more granularly.
110+ * E.g. multiply the configured outboundBatchInterval by groups of 100 members instead of the total number of members.
111+ */
112+ this . cursorBatching . setBatchTime ( Math . ceil ( cursorsMembers . length / 100 ) * this . options . outboundBatchInterval ) ;
109113 }
110114
111115 private isUnsubscribed ( ) {
You can’t perform that action at this time.
0 commit comments