Skip to content

Commit

Permalink
Change cursors batch time formula on presence update
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoDiasAbly committed Sep 4, 2024
1 parent 50d8899 commit 867a674
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Cursors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('Cursors', () => {
vi.spyOn(channel.presence, 'get').mockImplementation(createPresenceCount(2));
await cursors['onPresenceUpdate']();
expect(batching.shouldSend).toBeTruthy();
expect(batching.batchTime).toEqual(50);
expect(batching.batchTime).toEqual(25);
});

it<CursorsTestContext>('batchTime is updated when multiple people are present', async ({
Expand All @@ -126,7 +126,7 @@ describe('Cursors', () => {
}) => {
vi.spyOn(channel.presence, 'get').mockImplementation(createPresenceCount(2));
await cursors['onPresenceUpdate']();
expect(batching.batchTime).toEqual(50);
expect(batching.batchTime).toEqual(25);
});

describe('pushCursorPosition', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Cursors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default class Cursors extends EventEmitter<CursorsEventMap> {
const channel = this.getChannel();
const cursorsMembers = await channel.presence.get();
this.cursorBatching.setShouldSend(cursorsMembers.length > 1);
this.cursorBatching.setBatchTime(cursorsMembers.length * this.options.outboundBatchInterval);
this.cursorBatching.setBatchTime(Math.ceil(cursorsMembers.length / 100) * this.options.outboundBatchInterval);
}

private isUnsubscribed() {
Expand Down

0 comments on commit 867a674

Please sign in to comment.