Skip to content

Commit b8bfb86

Browse files
authored
Respect sliding sync setting (#1036)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description <!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. --> Fixes # #### Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. -->
2 parents 5a90343 + 22b51a7 commit b8bfb86

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
Fix sliding sync being enabled when setting is disabled.

src/client/initMatrix.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -402,37 +402,46 @@ export const startClient = async (mx: MatrixClient, config?: StartClientConfig):
402402
debugLog.info('sync', 'Starting Matrix client', { userId: mx.getUserId() });
403403
disposeSlidingSync(mx);
404404
disposePresenceSync(mx);
405+
405406
const slidingConfig = config?.slidingSync;
406407
const proxyBaseUrl = slidingConfig?.proxyBaseUrl ?? config?.baseUrl ?? mx.baseUrl;
407-
408-
const manager = new SlidingSyncManager(mx, proxyBaseUrl, {
409-
...slidingConfig,
410-
includeInviteList: true,
411-
pollTimeoutMs: slidingConfig?.pollTimeoutMs ?? SLIDING_SYNC_POLL_TIMEOUT_MS,
412-
});
408+
const useSliding =
409+
config?.sessionSlidingSyncOptIn === true &&
410+
!!slidingConfig &&
411+
resolveSlidingEnabled(slidingConfig?.enabled);
413412

414413
const presenceManager = new PresenceSyncManager(mx);
415414
presenceSyncByClient.set(mx, presenceManager);
416415

417416
presenceManager.start();
418417

419-
installStartupFetchRoomEventPatch(mx, manager);
420-
installSlidingSyncConnId(mx);
418+
let manager: SlidingSyncManager | undefined;
421419

422-
manager.attach();
423-
slidingSyncByClient.set(mx, manager);
420+
if (useSliding) {
421+
manager = new SlidingSyncManager(mx, proxyBaseUrl, {
422+
...slidingConfig,
423+
includeInviteList: true,
424+
pollTimeoutMs: slidingConfig?.pollTimeoutMs ?? SLIDING_SYNC_POLL_TIMEOUT_MS,
425+
});
426+
427+
installStartupFetchRoomEventPatch(mx, manager);
428+
installSlidingSyncConnId(mx);
429+
430+
manager.attach();
431+
slidingSyncByClient.set(mx, manager);
432+
}
424433

425434
try {
426435
await mx.startClient({
427436
lazyLoadMembers: true,
428-
slidingSync: manager.slidingSync,
437+
slidingSync: manager?.slidingSync,
429438
threadSupport: true,
430439
});
431440
} catch (err) {
432441
debugLog.error('network', 'Failed to start client with sliding sync', {
433442
error: err instanceof Error ? err.message : String(err),
434443
userId: mx.getUserId(),
435-
proxyBaseUrl: proxyBaseUrl,
444+
proxyBaseUrl: useSliding ? proxyBaseUrl : undefined,
436445
stack: err instanceof Error ? err.stack : undefined,
437446
});
438447
disposeSlidingSync(mx);

0 commit comments

Comments
 (0)