element-web-Github/src/SlidingSyncManager.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

411 lines
19 KiB
TypeScript
Raw Normal View History

Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
/*
Copyright 2024 New Vector Ltd.
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
Copyright 2022 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
*/
/*
* Sliding Sync Architecture - MSC https://github.com/matrix-org/matrix-spec-proposals/pull/3575
*
* This is a holistic summary of the changes made to Element-Web / React SDK / JS SDK to enable sliding sync.
* This summary will hopefully signpost where developers need to look if they want to make changes to this code.
*
* At the lowest level, the JS SDK contains an HTTP API wrapper function in client.ts. This is used by
* a SlidingSync class in JS SDK, which contains code to handle list operations (INSERT/DELETE/SYNC/etc)
* and contains the main request API bodies, but has no code to control updating JS SDK structures: it just
* exposes an EventEmitter to listen for updates. When MatrixClient.startClient is called, callers need to
* provide a SlidingSync instance as this contains the main request API params (timeline limit, required state,
* how many lists, etc).
*
* The SlidingSyncSdk INTERNAL class in JS SDK attaches listeners to SlidingSync to update JS SDK Room objects,
* and it conveniently exposes an identical public API to SyncApi (to allow it to be a drop-in replacement).
*
* At the highest level, SlidingSyncManager contains mechanisms to tell UI lists which rooms to show,
* and contains the core request API params used in Element-Web. It does this by listening for events
* emitted by the SlidingSync class and by modifying the request API params on the SlidingSync class.
*
* (entry point) (updates JS SDK)
* SlidingSyncManager SlidingSyncSdk
* | |
* +------------------.------------------+
* listens | listens
* SlidingSync
* (sync loop,
* list ops)
*/
MSC3575 (Sliding Sync) add well-known proxy support (#12307) * Initial commit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove commented code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change function to reflect it's proxy not native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add check for servers with native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add native support check back in Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add endpoint health check function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Use inbuilt `getWellKnown` function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change the error message to the correct function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Stop storing the proxyurl in the settings for now Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logger messages more useful Signed-off-by: Ed Geraghty <ed@geraghty.family> * Start moving the checking logic directly into the controller Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Get the client rather than passing it in to the functions Signed-off-by: Ed Geraghty <ed@geraghty.family> * remove invalid `function` keyword Signed-off-by: Ed Geraghty <ed@geraghty.family> * Fix imports Signed-off-by: Ed Geraghty <ed@geraghty.family> * Our new functions are private We shouldn't(?) have to use these check in future elsewhere Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change our proxy check function to return a boolean Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `nativeSlidingSyncSupport` also return boolean, add in health check Signed-off-by: Ed Geraghty <ed@geraghty.family> * Disable the sliding sync option if the server doesn't support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only enable the setting if it passes (again) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update our comments to better match what's going on Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused dialog Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add a well-known check on start-up, if sliding sync has been enabled Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check against the correct endpoint... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Extract baseUrl as we'll reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logs differentiate between the types of proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Grab the client well-known directly for use Can't use the client object at this point, it hasn't read in the well-known Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add myself to the copyright assignation I wrote the majority of this file... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only return `true` if it's actually there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `proxySlidingSyncSupport` function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `nativeSlidingSyncSupport`function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Another comment/functionality paring Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove duplicated types from the doc Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move await to the previous line Removes brackets, and corrects `wellKnown` from being a `Promise` Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `waitForClientWellKnown` to avoid a race condition with the request Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move getting the client out of the `if`, use `waitForClientWellKnown` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove `beforeChange` override Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move proxy setup logic into `SlidingSyncManager` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Swap `configure` to private, we call it from `setup` which handles proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Promises are always `true` TIL. Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `timeoutSignal` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change message when there's no server support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `slidingSyncHealthCheck` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `nativeSlidingSyncSupport` with try/catch Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change comment to hotlink Signed-off-by: Ed Geraghty <ed@geraghty.family> * Try and make the toggle disabled when there's no endpoint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the if statement outside the refactored fn to avoid an await Signed-off-by: Ed Geraghty <ed@geraghty.family> * Revert "Swap `configure` to private, we call it from `setup` which handles proxy" This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426. * Remove unused import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Further refactor `slidingSyncHealthCheck` `proxySlidingSyncSupport` already checks the client well-known is there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `proxySlidingSyncSupport` log on success Signed-off-by: Ed Geraghty <ed@geraghty.family> * Clarify log message for proxy being up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the logic into SlidingSyncManager All so we can set a static variable because the disabled check isn't asynchronous :) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Obviously this isn't a return so don't overwrite with false! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove outdated comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to pass in the client Signed-off-by: Ed Geraghty <ed@geraghty.family> * Activating SS should probably be info level logs Signed-off-by: Ed Geraghty <ed@geraghty.family> * If we've not enabled sliding sync, push the logs down a bit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update i18n error message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused i18n strings Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct log message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Prettier Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove many of the log messages Signed-off-by: Ed Geraghty <ed@geraghty.family> * Short out of `checkSupport` if it's `true` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add the endpoint back into the log when we're enabling it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Note in the comment that `feature_sliding_sync_proxy_url` is legacy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Expand the well-known liveness check log Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to stall the client waiting for sliding sync support * `AutoDiscovery.findClientConfig` throws if the baseUrl is blank * Fix `getProxyFromWellKnown` (?) * Add missing semicolon Sorry, linter! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pass our `MatrixClient` through instead of trying to grab it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing return in function comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * Actually pass through our Client, not the Peg object Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove SonarCube smell complaint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Neew to make our other two methods public to test Signed-off-by: Ed Geraghty <ed@geraghty.family> * First passing test Hurrah! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Two more tests, this time on `checkSupport` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Reset our `serverSupportsSlidingSync` between tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check the static member is being set Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the static assignation down to the relevant tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pull getProxyFromWellKnown mocking up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check we /haven't/ shorted out Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move our spy up so we can reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check spidering is being called Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test the proxy is declared Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test entered manually Signed-off-by: Ed Geraghty <ed@geraghty.family> * Sorry, linter * I guess these strings are wrong? * Replace any with string Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Ed Geraghty <ed@geraghty.family> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
import { MatrixClient, EventType, AutoDiscovery, Method, timeoutSignal } from "matrix-js-sdk/src/matrix";
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
import {
MSC3575Filter,
MSC3575List,
MSC3575_STATE_KEY_LAZY,
MSC3575_STATE_KEY_ME,
MSC3575_WILDCARD,
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
SlidingSync,
} from "matrix-js-sdk/src/sliding-sync";
import { logger } from "matrix-js-sdk/src/logger";
import { defer, sleep } from "matrix-js-sdk/src/utils";
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
MSC3575 (Sliding Sync) add well-known proxy support (#12307) * Initial commit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove commented code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change function to reflect it's proxy not native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add check for servers with native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add native support check back in Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add endpoint health check function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Use inbuilt `getWellKnown` function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change the error message to the correct function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Stop storing the proxyurl in the settings for now Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logger messages more useful Signed-off-by: Ed Geraghty <ed@geraghty.family> * Start moving the checking logic directly into the controller Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Get the client rather than passing it in to the functions Signed-off-by: Ed Geraghty <ed@geraghty.family> * remove invalid `function` keyword Signed-off-by: Ed Geraghty <ed@geraghty.family> * Fix imports Signed-off-by: Ed Geraghty <ed@geraghty.family> * Our new functions are private We shouldn't(?) have to use these check in future elsewhere Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change our proxy check function to return a boolean Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `nativeSlidingSyncSupport` also return boolean, add in health check Signed-off-by: Ed Geraghty <ed@geraghty.family> * Disable the sliding sync option if the server doesn't support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only enable the setting if it passes (again) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update our comments to better match what's going on Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused dialog Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add a well-known check on start-up, if sliding sync has been enabled Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check against the correct endpoint... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Extract baseUrl as we'll reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logs differentiate between the types of proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Grab the client well-known directly for use Can't use the client object at this point, it hasn't read in the well-known Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add myself to the copyright assignation I wrote the majority of this file... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only return `true` if it's actually there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `proxySlidingSyncSupport` function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `nativeSlidingSyncSupport`function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Another comment/functionality paring Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove duplicated types from the doc Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move await to the previous line Removes brackets, and corrects `wellKnown` from being a `Promise` Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `waitForClientWellKnown` to avoid a race condition with the request Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move getting the client out of the `if`, use `waitForClientWellKnown` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove `beforeChange` override Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move proxy setup logic into `SlidingSyncManager` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Swap `configure` to private, we call it from `setup` which handles proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Promises are always `true` TIL. Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `timeoutSignal` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change message when there's no server support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `slidingSyncHealthCheck` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `nativeSlidingSyncSupport` with try/catch Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change comment to hotlink Signed-off-by: Ed Geraghty <ed@geraghty.family> * Try and make the toggle disabled when there's no endpoint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the if statement outside the refactored fn to avoid an await Signed-off-by: Ed Geraghty <ed@geraghty.family> * Revert "Swap `configure` to private, we call it from `setup` which handles proxy" This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426. * Remove unused import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Further refactor `slidingSyncHealthCheck` `proxySlidingSyncSupport` already checks the client well-known is there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `proxySlidingSyncSupport` log on success Signed-off-by: Ed Geraghty <ed@geraghty.family> * Clarify log message for proxy being up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the logic into SlidingSyncManager All so we can set a static variable because the disabled check isn't asynchronous :) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Obviously this isn't a return so don't overwrite with false! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove outdated comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to pass in the client Signed-off-by: Ed Geraghty <ed@geraghty.family> * Activating SS should probably be info level logs Signed-off-by: Ed Geraghty <ed@geraghty.family> * If we've not enabled sliding sync, push the logs down a bit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update i18n error message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused i18n strings Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct log message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Prettier Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove many of the log messages Signed-off-by: Ed Geraghty <ed@geraghty.family> * Short out of `checkSupport` if it's `true` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add the endpoint back into the log when we're enabling it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Note in the comment that `feature_sliding_sync_proxy_url` is legacy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Expand the well-known liveness check log Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to stall the client waiting for sliding sync support * `AutoDiscovery.findClientConfig` throws if the baseUrl is blank * Fix `getProxyFromWellKnown` (?) * Add missing semicolon Sorry, linter! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pass our `MatrixClient` through instead of trying to grab it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing return in function comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * Actually pass through our Client, not the Peg object Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove SonarCube smell complaint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Neew to make our other two methods public to test Signed-off-by: Ed Geraghty <ed@geraghty.family> * First passing test Hurrah! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Two more tests, this time on `checkSupport` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Reset our `serverSupportsSlidingSync` between tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check the static member is being set Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the static assignation down to the relevant tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pull getProxyFromWellKnown mocking up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check we /haven't/ shorted out Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move our spy up so we can reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check spidering is being called Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test the proxy is declared Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test entered manually Signed-off-by: Ed Geraghty <ed@geraghty.family> * Sorry, linter * I guess these strings are wrong? * Replace any with string Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Ed Geraghty <ed@geraghty.family> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
import SettingsStore from "./settings/SettingsStore";
import SlidingSyncController from "./settings/controllers/SlidingSyncController";
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
// how long to long poll for
const SLIDING_SYNC_TIMEOUT_MS = 20 * 1000;
// the things to fetch when a user clicks on a room
const DEFAULT_ROOM_SUBSCRIPTION_INFO = {
timeline_limit: 50,
// missing required_state which will change depending on the kind of room
include_old_rooms: {
timeline_limit: 0,
required_state: [
// state needed to handle space navigation and tombstone chains
[EventType.RoomCreate, ""],
[EventType.RoomTombstone, ""],
[EventType.SpaceChild, MSC3575_WILDCARD],
[EventType.SpaceParent, MSC3575_WILDCARD],
[EventType.RoomMember, MSC3575_STATE_KEY_ME],
],
},
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
};
// lazy load room members so rooms like Matrix HQ don't take forever to load
const UNENCRYPTED_SUBSCRIPTION_NAME = "unencrypted";
const UNENCRYPTED_SUBSCRIPTION = Object.assign(
{
required_state: [
[MSC3575_WILDCARD, MSC3575_WILDCARD], // all events
[EventType.RoomMember, MSC3575_STATE_KEY_ME], // except for m.room.members, get our own membership
[EventType.RoomMember, MSC3575_STATE_KEY_LAZY], // ...and lazy load the rest.
],
},
DEFAULT_ROOM_SUBSCRIPTION_INFO,
);
// we need all the room members in encrypted rooms because we need to know which users to encrypt
// messages for.
const ENCRYPTED_SUBSCRIPTION = Object.assign(
{
required_state: [
[MSC3575_WILDCARD, MSC3575_WILDCARD], // all events
],
},
DEFAULT_ROOM_SUBSCRIPTION_INFO,
);
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
export type PartialSlidingSyncRequest = {
filters?: MSC3575Filter;
sort?: string[];
ranges?: [startIndex: number, endIndex: number][];
};
/**
* This class manages the entirety of sliding sync at a high UI/UX level. It controls the placement
* of placeholders in lists, controls updating sliding window ranges, and controls which events
* are pulled down when. The intention behind this manager is be the single place to look for sliding
* sync options and code.
*/
export class SlidingSyncManager {
public static readonly ListSpaces = "space_list";
public static readonly ListSearch = "search_list";
private static readonly internalInstance = new SlidingSyncManager();
public slidingSync?: SlidingSync;
private client?: MatrixClient;
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
private configureDefer = defer<void>();
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
public static get instance(): SlidingSyncManager {
return SlidingSyncManager.internalInstance;
}
public configure(client: MatrixClient, proxyUrl: string): SlidingSync {
this.client = client;
// by default use the encrypted subscription as that gets everything, which is a safer
// default than potentially missing member events.
2023-01-19 19:02:43 +08:00
this.slidingSync = new SlidingSync(
proxyUrl,
new Map(),
ENCRYPTED_SUBSCRIPTION,
client,
SLIDING_SYNC_TIMEOUT_MS,
);
this.slidingSync.addCustomSubscription(UNENCRYPTED_SUBSCRIPTION_NAME, UNENCRYPTED_SUBSCRIPTION);
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
// set the space list
this.slidingSync.setList(SlidingSyncManager.ListSpaces, {
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
ranges: [[0, 20]],
sort: ["by_name"],
slow_get_all_rooms: true,
timeline_limit: 0,
required_state: [
[EventType.RoomJoinRules, ""], // the public icon on the room list
[EventType.RoomAvatar, ""], // any room avatar
[EventType.RoomTombstone, ""], // lets JS SDK hide rooms which are dead
[EventType.RoomEncryption, ""], // lets rooms be configured for E2EE correctly
[EventType.RoomCreate, ""], // for isSpaceRoom checks
[EventType.SpaceChild, MSC3575_WILDCARD], // all space children
[EventType.SpaceParent, MSC3575_WILDCARD], // all space parents
[EventType.RoomMember, MSC3575_STATE_KEY_ME], // lets the client calculate that we are in fact in the room
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
],
include_old_rooms: {
timeline_limit: 0,
required_state: [
[EventType.RoomCreate, ""],
[EventType.RoomTombstone, ""], // lets JS SDK hide rooms which are dead
[EventType.SpaceChild, MSC3575_WILDCARD], // all space children
[EventType.SpaceParent, MSC3575_WILDCARD], // all space parents
[EventType.RoomMember, MSC3575_STATE_KEY_ME], // lets the client calculate that we are in fact in the room
],
},
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
filters: {
room_types: ["m.space"],
},
});
this.configureDefer.resolve();
return this.slidingSync;
}
/**
* Ensure that this list is registered.
* @param listKey The list key to register
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
* @param updateArgs The fields to update on the list.
* @returns The complete list request params
*/
public async ensureListRegistered(listKey: string, updateArgs: PartialSlidingSyncRequest): Promise<MSC3575List> {
logger.debug("ensureListRegistered:::", listKey, updateArgs);
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
await this.configureDefer.promise;
let list = this.slidingSync!.getListParams(listKey);
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
if (!list) {
list = {
ranges: [[0, 20]],
sort: ["by_notification_level", "by_recency"],
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
timeline_limit: 1, // most recent message display: though this seems to only be needed for favourites?
required_state: [
[EventType.RoomJoinRules, ""], // the public icon on the room list
[EventType.RoomAvatar, ""], // any room avatar
[EventType.RoomTombstone, ""], // lets JS SDK hide rooms which are dead
[EventType.RoomEncryption, ""], // lets rooms be configured for E2EE correctly
[EventType.RoomCreate, ""], // for isSpaceRoom checks
[EventType.RoomMember, MSC3575_STATE_KEY_ME], // lets the client calculate that we are in fact in the room
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
],
include_old_rooms: {
timeline_limit: 0,
required_state: [
[EventType.RoomCreate, ""],
[EventType.RoomTombstone, ""], // lets JS SDK hide rooms which are dead
[EventType.SpaceChild, MSC3575_WILDCARD], // all space children
[EventType.SpaceParent, MSC3575_WILDCARD], // all space parents
[EventType.RoomMember, MSC3575_STATE_KEY_ME], // lets the client calculate that we are in fact in the room
],
},
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
};
list = Object.assign(list, updateArgs);
} else {
const updatedList = Object.assign({}, list, updateArgs);
// cannot use objectHasDiff as we need to do deep diff checking
if (JSON.stringify(list) === JSON.stringify(updatedList)) {
logger.debug("list matches, not sending, update => ", updateArgs);
return list;
}
list = updatedList;
}
try {
// if we only have range changes then call a different function so we don't nuke the list from before
if (updateArgs.ranges && Object.keys(updateArgs).length === 1) {
await this.slidingSync!.setListRanges(listKey, updateArgs.ranges);
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
} else {
await this.slidingSync!.setList(listKey, list);
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
}
} catch (err) {
logger.debug("ensureListRegistered: update failed txn_id=", err);
}
return this.slidingSync!.getListParams(listKey)!;
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
}
public async setRoomVisible(roomId: string, visible: boolean): Promise<string> {
await this.configureDefer.promise;
const subscriptions = this.slidingSync!.getRoomSubscriptions();
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
if (visible) {
subscriptions.add(roomId);
} else {
subscriptions.delete(roomId);
}
const room = this.client?.getRoom(roomId);
let shouldLazyLoad = !this.client?.isRoomEncrypted(roomId);
if (!room) {
// default to safety: request all state if we can't work it out. This can happen if you
// refresh the app whilst viewing a room: we call setRoomVisible before we know anything
// about the room.
shouldLazyLoad = false;
}
logger.log("SlidingSync setRoomVisible:", roomId, visible, "shouldLazyLoad:", shouldLazyLoad);
if (shouldLazyLoad) {
// lazy load this room
this.slidingSync!.useCustomSubscription(roomId, UNENCRYPTED_SUBSCRIPTION_NAME);
}
const p = this.slidingSync!.modifyRoomSubscriptions(subscriptions);
if (room) {
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
return roomId; // we have data already for this room, show immediately e.g it's in a list
}
try {
// wait until the next sync before returning as RoomView may need to know the current state
await p;
} catch (err) {
logger.warn("SlidingSync setRoomVisible:", roomId, visible, "failed to confirm transaction");
}
return roomId;
}
/**
* Retrieve all rooms on the user's account. Used for pre-populating the local search cache.
* Retrieval is gradual over time.
* @param batchSize The number of rooms to return in each request.
* @param gapBetweenRequestsMs The number of milliseconds to wait between requests.
*/
public async startSpidering(batchSize: number, gapBetweenRequestsMs: number): Promise<void> {
await sleep(gapBetweenRequestsMs); // wait a bit as this is called on first render so let's let things load
let startIndex = batchSize;
let hasMore = true;
let firstTime = true;
while (hasMore) {
const endIndex = startIndex + batchSize - 1;
try {
const ranges = [
[0, batchSize - 1],
[startIndex, endIndex],
];
if (firstTime) {
await this.slidingSync!.setList(SlidingSyncManager.ListSearch, {
// e.g [0,19] [20,39] then [0,19] [40,59]. We keep [0,20] constantly to ensure
// any changes to the list whilst spidering are caught.
ranges: ranges,
sort: [
"by_recency", // this list isn't shown on the UI so just sorting by timestamp is enough
],
timeline_limit: 0, // we only care about the room details, not messages in the room
required_state: [
[EventType.RoomJoinRules, ""], // the public icon on the room list
[EventType.RoomAvatar, ""], // any room avatar
[EventType.RoomTombstone, ""], // lets JS SDK hide rooms which are dead
[EventType.RoomEncryption, ""], // lets rooms be configured for E2EE correctly
[EventType.RoomCreate, ""], // for isSpaceRoom checks
[EventType.RoomMember, MSC3575_STATE_KEY_ME], // lets the client calculate that we are in fact in the room
],
// we don't include_old_rooms here in an effort to reduce the impact of spidering all rooms
// on the user's account. This means some data in the search dialog results may be inaccurate
// e.g membership of space, but this will be corrected when the user clicks on the room
// as the direct room subscription does include old room iterations.
filters: {
// we get spaces via a different list, so filter them out
not_room_types: ["m.space"],
},
});
} else {
await this.slidingSync!.setListRanges(SlidingSyncManager.ListSearch, ranges);
}
} catch (err) {
// do nothing, as we reject only when we get interrupted but that's fine as the next
// request will include our data
2023-01-20 18:31:44 +08:00
} finally {
// gradually request more over time, even on errors.
await sleep(gapBetweenRequestsMs);
}
const listData = this.slidingSync!.getListData(SlidingSyncManager.ListSearch)!;
2023-01-20 18:31:44 +08:00
hasMore = endIndex + 1 < listData.joinedCount;
startIndex += batchSize;
firstTime = false;
}
}
MSC3575 (Sliding Sync) add well-known proxy support (#12307) * Initial commit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove commented code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change function to reflect it's proxy not native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add check for servers with native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add native support check back in Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add endpoint health check function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Use inbuilt `getWellKnown` function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change the error message to the correct function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Stop storing the proxyurl in the settings for now Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logger messages more useful Signed-off-by: Ed Geraghty <ed@geraghty.family> * Start moving the checking logic directly into the controller Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Get the client rather than passing it in to the functions Signed-off-by: Ed Geraghty <ed@geraghty.family> * remove invalid `function` keyword Signed-off-by: Ed Geraghty <ed@geraghty.family> * Fix imports Signed-off-by: Ed Geraghty <ed@geraghty.family> * Our new functions are private We shouldn't(?) have to use these check in future elsewhere Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change our proxy check function to return a boolean Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `nativeSlidingSyncSupport` also return boolean, add in health check Signed-off-by: Ed Geraghty <ed@geraghty.family> * Disable the sliding sync option if the server doesn't support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only enable the setting if it passes (again) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update our comments to better match what's going on Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused dialog Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add a well-known check on start-up, if sliding sync has been enabled Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check against the correct endpoint... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Extract baseUrl as we'll reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logs differentiate between the types of proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Grab the client well-known directly for use Can't use the client object at this point, it hasn't read in the well-known Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add myself to the copyright assignation I wrote the majority of this file... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only return `true` if it's actually there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `proxySlidingSyncSupport` function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `nativeSlidingSyncSupport`function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Another comment/functionality paring Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove duplicated types from the doc Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move await to the previous line Removes brackets, and corrects `wellKnown` from being a `Promise` Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `waitForClientWellKnown` to avoid a race condition with the request Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move getting the client out of the `if`, use `waitForClientWellKnown` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove `beforeChange` override Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move proxy setup logic into `SlidingSyncManager` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Swap `configure` to private, we call it from `setup` which handles proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Promises are always `true` TIL. Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `timeoutSignal` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change message when there's no server support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `slidingSyncHealthCheck` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `nativeSlidingSyncSupport` with try/catch Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change comment to hotlink Signed-off-by: Ed Geraghty <ed@geraghty.family> * Try and make the toggle disabled when there's no endpoint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the if statement outside the refactored fn to avoid an await Signed-off-by: Ed Geraghty <ed@geraghty.family> * Revert "Swap `configure` to private, we call it from `setup` which handles proxy" This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426. * Remove unused import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Further refactor `slidingSyncHealthCheck` `proxySlidingSyncSupport` already checks the client well-known is there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `proxySlidingSyncSupport` log on success Signed-off-by: Ed Geraghty <ed@geraghty.family> * Clarify log message for proxy being up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the logic into SlidingSyncManager All so we can set a static variable because the disabled check isn't asynchronous :) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Obviously this isn't a return so don't overwrite with false! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove outdated comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to pass in the client Signed-off-by: Ed Geraghty <ed@geraghty.family> * Activating SS should probably be info level logs Signed-off-by: Ed Geraghty <ed@geraghty.family> * If we've not enabled sliding sync, push the logs down a bit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update i18n error message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused i18n strings Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct log message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Prettier Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove many of the log messages Signed-off-by: Ed Geraghty <ed@geraghty.family> * Short out of `checkSupport` if it's `true` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add the endpoint back into the log when we're enabling it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Note in the comment that `feature_sliding_sync_proxy_url` is legacy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Expand the well-known liveness check log Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to stall the client waiting for sliding sync support * `AutoDiscovery.findClientConfig` throws if the baseUrl is blank * Fix `getProxyFromWellKnown` (?) * Add missing semicolon Sorry, linter! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pass our `MatrixClient` through instead of trying to grab it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing return in function comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * Actually pass through our Client, not the Peg object Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove SonarCube smell complaint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Neew to make our other two methods public to test Signed-off-by: Ed Geraghty <ed@geraghty.family> * First passing test Hurrah! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Two more tests, this time on `checkSupport` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Reset our `serverSupportsSlidingSync` between tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check the static member is being set Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the static assignation down to the relevant tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pull getProxyFromWellKnown mocking up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check we /haven't/ shorted out Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move our spy up so we can reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check spidering is being called Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test the proxy is declared Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test entered manually Signed-off-by: Ed Geraghty <ed@geraghty.family> * Sorry, linter * I guess these strings are wrong? * Replace any with string Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Ed Geraghty <ed@geraghty.family> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
/**
* Set up the Sliding Sync instance; configures the end point and starts spidering.
* The sliding sync endpoint is derived the following way:
* 1. The user-defined sliding sync proxy URL (legacy, for backwards compatibility)
* 2. The client `well-known` sliding sync proxy URL [declared at the unstable prefix](https://github.com/matrix-org/matrix-spec-proposals/blob/kegan/sync-v3/proposals/3575-sync.md#unstable-prefix)
* 3. The homeserver base url (for native server support)
* @param client The MatrixClient to use
* @returns A working Sliding Sync or undefined
*/
public async setup(client: MatrixClient): Promise<SlidingSync | undefined> {
const baseUrl = client.baseUrl;
const proxyUrl = SettingsStore.getValue("feature_sliding_sync_proxy_url");
const wellKnownProxyUrl = await this.getProxyFromWellKnown(client);
const slidingSyncEndpoint = proxyUrl || wellKnownProxyUrl || baseUrl;
this.configure(client, slidingSyncEndpoint);
logger.info("Sliding sync activated at", slidingSyncEndpoint);
this.startSpidering(100, 50); // 100 rooms at a time, 50ms apart
return this.slidingSync;
}
/**
* Get the sliding sync proxy URL from the client well known
* @param client The MatrixClient to use
* @return The proxy url
*/
public async getProxyFromWellKnown(client: MatrixClient): Promise<string | undefined> {
let proxyUrl: string | undefined;
try {
const clientDomain = await client.getDomain();
if (clientDomain === null) {
throw new RangeError("Homeserver domain is null");
}
const clientWellKnown = await AutoDiscovery.findClientConfig(clientDomain);
MSC3575 (Sliding Sync) add well-known proxy support (#12307) * Initial commit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove commented code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change function to reflect it's proxy not native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add check for servers with native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add native support check back in Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add endpoint health check function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Use inbuilt `getWellKnown` function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change the error message to the correct function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Stop storing the proxyurl in the settings for now Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logger messages more useful Signed-off-by: Ed Geraghty <ed@geraghty.family> * Start moving the checking logic directly into the controller Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Get the client rather than passing it in to the functions Signed-off-by: Ed Geraghty <ed@geraghty.family> * remove invalid `function` keyword Signed-off-by: Ed Geraghty <ed@geraghty.family> * Fix imports Signed-off-by: Ed Geraghty <ed@geraghty.family> * Our new functions are private We shouldn't(?) have to use these check in future elsewhere Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change our proxy check function to return a boolean Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `nativeSlidingSyncSupport` also return boolean, add in health check Signed-off-by: Ed Geraghty <ed@geraghty.family> * Disable the sliding sync option if the server doesn't support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only enable the setting if it passes (again) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update our comments to better match what's going on Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused dialog Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add a well-known check on start-up, if sliding sync has been enabled Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check against the correct endpoint... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Extract baseUrl as we'll reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logs differentiate between the types of proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Grab the client well-known directly for use Can't use the client object at this point, it hasn't read in the well-known Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add myself to the copyright assignation I wrote the majority of this file... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only return `true` if it's actually there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `proxySlidingSyncSupport` function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `nativeSlidingSyncSupport`function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Another comment/functionality paring Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove duplicated types from the doc Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move await to the previous line Removes brackets, and corrects `wellKnown` from being a `Promise` Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `waitForClientWellKnown` to avoid a race condition with the request Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move getting the client out of the `if`, use `waitForClientWellKnown` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove `beforeChange` override Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move proxy setup logic into `SlidingSyncManager` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Swap `configure` to private, we call it from `setup` which handles proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Promises are always `true` TIL. Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `timeoutSignal` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change message when there's no server support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `slidingSyncHealthCheck` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `nativeSlidingSyncSupport` with try/catch Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change comment to hotlink Signed-off-by: Ed Geraghty <ed@geraghty.family> * Try and make the toggle disabled when there's no endpoint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the if statement outside the refactored fn to avoid an await Signed-off-by: Ed Geraghty <ed@geraghty.family> * Revert "Swap `configure` to private, we call it from `setup` which handles proxy" This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426. * Remove unused import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Further refactor `slidingSyncHealthCheck` `proxySlidingSyncSupport` already checks the client well-known is there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `proxySlidingSyncSupport` log on success Signed-off-by: Ed Geraghty <ed@geraghty.family> * Clarify log message for proxy being up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the logic into SlidingSyncManager All so we can set a static variable because the disabled check isn't asynchronous :) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Obviously this isn't a return so don't overwrite with false! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove outdated comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to pass in the client Signed-off-by: Ed Geraghty <ed@geraghty.family> * Activating SS should probably be info level logs Signed-off-by: Ed Geraghty <ed@geraghty.family> * If we've not enabled sliding sync, push the logs down a bit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update i18n error message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused i18n strings Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct log message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Prettier Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove many of the log messages Signed-off-by: Ed Geraghty <ed@geraghty.family> * Short out of `checkSupport` if it's `true` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add the endpoint back into the log when we're enabling it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Note in the comment that `feature_sliding_sync_proxy_url` is legacy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Expand the well-known liveness check log Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to stall the client waiting for sliding sync support * `AutoDiscovery.findClientConfig` throws if the baseUrl is blank * Fix `getProxyFromWellKnown` (?) * Add missing semicolon Sorry, linter! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pass our `MatrixClient` through instead of trying to grab it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing return in function comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * Actually pass through our Client, not the Peg object Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove SonarCube smell complaint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Neew to make our other two methods public to test Signed-off-by: Ed Geraghty <ed@geraghty.family> * First passing test Hurrah! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Two more tests, this time on `checkSupport` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Reset our `serverSupportsSlidingSync` between tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check the static member is being set Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the static assignation down to the relevant tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pull getProxyFromWellKnown mocking up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check we /haven't/ shorted out Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move our spy up so we can reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check spidering is being called Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test the proxy is declared Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test entered manually Signed-off-by: Ed Geraghty <ed@geraghty.family> * Sorry, linter * I guess these strings are wrong? * Replace any with string Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Ed Geraghty <ed@geraghty.family> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
proxyUrl = clientWellKnown?.["org.matrix.msc3575.proxy"]?.url;
} catch (e) {
// Either client.getDomain() is null so we've shorted out, or is invalid so `AutoDiscovery.findClientConfig` has thrown
MSC3575 (Sliding Sync) add well-known proxy support (#12307) * Initial commit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove commented code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change function to reflect it's proxy not native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add check for servers with native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add native support check back in Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add endpoint health check function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Use inbuilt `getWellKnown` function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change the error message to the correct function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Stop storing the proxyurl in the settings for now Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logger messages more useful Signed-off-by: Ed Geraghty <ed@geraghty.family> * Start moving the checking logic directly into the controller Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Get the client rather than passing it in to the functions Signed-off-by: Ed Geraghty <ed@geraghty.family> * remove invalid `function` keyword Signed-off-by: Ed Geraghty <ed@geraghty.family> * Fix imports Signed-off-by: Ed Geraghty <ed@geraghty.family> * Our new functions are private We shouldn't(?) have to use these check in future elsewhere Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change our proxy check function to return a boolean Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `nativeSlidingSyncSupport` also return boolean, add in health check Signed-off-by: Ed Geraghty <ed@geraghty.family> * Disable the sliding sync option if the server doesn't support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only enable the setting if it passes (again) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update our comments to better match what's going on Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused dialog Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add a well-known check on start-up, if sliding sync has been enabled Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check against the correct endpoint... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Extract baseUrl as we'll reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logs differentiate between the types of proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Grab the client well-known directly for use Can't use the client object at this point, it hasn't read in the well-known Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add myself to the copyright assignation I wrote the majority of this file... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only return `true` if it's actually there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `proxySlidingSyncSupport` function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `nativeSlidingSyncSupport`function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Another comment/functionality paring Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove duplicated types from the doc Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move await to the previous line Removes brackets, and corrects `wellKnown` from being a `Promise` Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `waitForClientWellKnown` to avoid a race condition with the request Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move getting the client out of the `if`, use `waitForClientWellKnown` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove `beforeChange` override Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move proxy setup logic into `SlidingSyncManager` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Swap `configure` to private, we call it from `setup` which handles proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Promises are always `true` TIL. Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `timeoutSignal` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change message when there's no server support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `slidingSyncHealthCheck` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `nativeSlidingSyncSupport` with try/catch Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change comment to hotlink Signed-off-by: Ed Geraghty <ed@geraghty.family> * Try and make the toggle disabled when there's no endpoint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the if statement outside the refactored fn to avoid an await Signed-off-by: Ed Geraghty <ed@geraghty.family> * Revert "Swap `configure` to private, we call it from `setup` which handles proxy" This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426. * Remove unused import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Further refactor `slidingSyncHealthCheck` `proxySlidingSyncSupport` already checks the client well-known is there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `proxySlidingSyncSupport` log on success Signed-off-by: Ed Geraghty <ed@geraghty.family> * Clarify log message for proxy being up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the logic into SlidingSyncManager All so we can set a static variable because the disabled check isn't asynchronous :) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Obviously this isn't a return so don't overwrite with false! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove outdated comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to pass in the client Signed-off-by: Ed Geraghty <ed@geraghty.family> * Activating SS should probably be info level logs Signed-off-by: Ed Geraghty <ed@geraghty.family> * If we've not enabled sliding sync, push the logs down a bit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update i18n error message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused i18n strings Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct log message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Prettier Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove many of the log messages Signed-off-by: Ed Geraghty <ed@geraghty.family> * Short out of `checkSupport` if it's `true` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add the endpoint back into the log when we're enabling it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Note in the comment that `feature_sliding_sync_proxy_url` is legacy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Expand the well-known liveness check log Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to stall the client waiting for sliding sync support * `AutoDiscovery.findClientConfig` throws if the baseUrl is blank * Fix `getProxyFromWellKnown` (?) * Add missing semicolon Sorry, linter! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pass our `MatrixClient` through instead of trying to grab it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing return in function comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * Actually pass through our Client, not the Peg object Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove SonarCube smell complaint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Neew to make our other two methods public to test Signed-off-by: Ed Geraghty <ed@geraghty.family> * First passing test Hurrah! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Two more tests, this time on `checkSupport` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Reset our `serverSupportsSlidingSync` between tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check the static member is being set Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the static assignation down to the relevant tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pull getProxyFromWellKnown mocking up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check we /haven't/ shorted out Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move our spy up so we can reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check spidering is being called Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test the proxy is declared Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test entered manually Signed-off-by: Ed Geraghty <ed@geraghty.family> * Sorry, linter * I guess these strings are wrong? * Replace any with string Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Ed Geraghty <ed@geraghty.family> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
}
if (proxyUrl != undefined) {
logger.log("getProxyFromWellKnown: client well-known declares sliding sync proxy at", proxyUrl);
}
return proxyUrl;
}
/**
* Check if the server "natively" supports sliding sync (with an unstable endpoint).
MSC3575 (Sliding Sync) add well-known proxy support (#12307) * Initial commit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove commented code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change function to reflect it's proxy not native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add check for servers with native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add native support check back in Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add endpoint health check function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Use inbuilt `getWellKnown` function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change the error message to the correct function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Stop storing the proxyurl in the settings for now Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logger messages more useful Signed-off-by: Ed Geraghty <ed@geraghty.family> * Start moving the checking logic directly into the controller Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Get the client rather than passing it in to the functions Signed-off-by: Ed Geraghty <ed@geraghty.family> * remove invalid `function` keyword Signed-off-by: Ed Geraghty <ed@geraghty.family> * Fix imports Signed-off-by: Ed Geraghty <ed@geraghty.family> * Our new functions are private We shouldn't(?) have to use these check in future elsewhere Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change our proxy check function to return a boolean Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `nativeSlidingSyncSupport` also return boolean, add in health check Signed-off-by: Ed Geraghty <ed@geraghty.family> * Disable the sliding sync option if the server doesn't support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only enable the setting if it passes (again) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update our comments to better match what's going on Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused dialog Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add a well-known check on start-up, if sliding sync has been enabled Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check against the correct endpoint... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Extract baseUrl as we'll reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logs differentiate between the types of proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Grab the client well-known directly for use Can't use the client object at this point, it hasn't read in the well-known Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add myself to the copyright assignation I wrote the majority of this file... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only return `true` if it's actually there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `proxySlidingSyncSupport` function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `nativeSlidingSyncSupport`function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Another comment/functionality paring Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove duplicated types from the doc Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move await to the previous line Removes brackets, and corrects `wellKnown` from being a `Promise` Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `waitForClientWellKnown` to avoid a race condition with the request Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move getting the client out of the `if`, use `waitForClientWellKnown` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove `beforeChange` override Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move proxy setup logic into `SlidingSyncManager` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Swap `configure` to private, we call it from `setup` which handles proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Promises are always `true` TIL. Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `timeoutSignal` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change message when there's no server support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `slidingSyncHealthCheck` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `nativeSlidingSyncSupport` with try/catch Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change comment to hotlink Signed-off-by: Ed Geraghty <ed@geraghty.family> * Try and make the toggle disabled when there's no endpoint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the if statement outside the refactored fn to avoid an await Signed-off-by: Ed Geraghty <ed@geraghty.family> * Revert "Swap `configure` to private, we call it from `setup` which handles proxy" This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426. * Remove unused import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Further refactor `slidingSyncHealthCheck` `proxySlidingSyncSupport` already checks the client well-known is there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `proxySlidingSyncSupport` log on success Signed-off-by: Ed Geraghty <ed@geraghty.family> * Clarify log message for proxy being up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the logic into SlidingSyncManager All so we can set a static variable because the disabled check isn't asynchronous :) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Obviously this isn't a return so don't overwrite with false! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove outdated comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to pass in the client Signed-off-by: Ed Geraghty <ed@geraghty.family> * Activating SS should probably be info level logs Signed-off-by: Ed Geraghty <ed@geraghty.family> * If we've not enabled sliding sync, push the logs down a bit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update i18n error message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused i18n strings Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct log message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Prettier Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove many of the log messages Signed-off-by: Ed Geraghty <ed@geraghty.family> * Short out of `checkSupport` if it's `true` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add the endpoint back into the log when we're enabling it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Note in the comment that `feature_sliding_sync_proxy_url` is legacy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Expand the well-known liveness check log Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to stall the client waiting for sliding sync support * `AutoDiscovery.findClientConfig` throws if the baseUrl is blank * Fix `getProxyFromWellKnown` (?) * Add missing semicolon Sorry, linter! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pass our `MatrixClient` through instead of trying to grab it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing return in function comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * Actually pass through our Client, not the Peg object Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove SonarCube smell complaint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Neew to make our other two methods public to test Signed-off-by: Ed Geraghty <ed@geraghty.family> * First passing test Hurrah! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Two more tests, this time on `checkSupport` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Reset our `serverSupportsSlidingSync` between tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check the static member is being set Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the static assignation down to the relevant tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pull getProxyFromWellKnown mocking up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check we /haven't/ shorted out Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move our spy up so we can reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check spidering is being called Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test the proxy is declared Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test entered manually Signed-off-by: Ed Geraghty <ed@geraghty.family> * Sorry, linter * I guess these strings are wrong? * Replace any with string Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Ed Geraghty <ed@geraghty.family> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
* @param client The MatrixClient to use
* @return Whether the "native" (unstable) endpoint is supported
MSC3575 (Sliding Sync) add well-known proxy support (#12307) * Initial commit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove commented code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change function to reflect it's proxy not native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add check for servers with native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add native support check back in Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add endpoint health check function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Use inbuilt `getWellKnown` function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change the error message to the correct function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Stop storing the proxyurl in the settings for now Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logger messages more useful Signed-off-by: Ed Geraghty <ed@geraghty.family> * Start moving the checking logic directly into the controller Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Get the client rather than passing it in to the functions Signed-off-by: Ed Geraghty <ed@geraghty.family> * remove invalid `function` keyword Signed-off-by: Ed Geraghty <ed@geraghty.family> * Fix imports Signed-off-by: Ed Geraghty <ed@geraghty.family> * Our new functions are private We shouldn't(?) have to use these check in future elsewhere Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change our proxy check function to return a boolean Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `nativeSlidingSyncSupport` also return boolean, add in health check Signed-off-by: Ed Geraghty <ed@geraghty.family> * Disable the sliding sync option if the server doesn't support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only enable the setting if it passes (again) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update our comments to better match what's going on Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused dialog Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add a well-known check on start-up, if sliding sync has been enabled Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check against the correct endpoint... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Extract baseUrl as we'll reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logs differentiate between the types of proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Grab the client well-known directly for use Can't use the client object at this point, it hasn't read in the well-known Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add myself to the copyright assignation I wrote the majority of this file... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only return `true` if it's actually there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `proxySlidingSyncSupport` function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `nativeSlidingSyncSupport`function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Another comment/functionality paring Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove duplicated types from the doc Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move await to the previous line Removes brackets, and corrects `wellKnown` from being a `Promise` Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `waitForClientWellKnown` to avoid a race condition with the request Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move getting the client out of the `if`, use `waitForClientWellKnown` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove `beforeChange` override Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move proxy setup logic into `SlidingSyncManager` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Swap `configure` to private, we call it from `setup` which handles proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Promises are always `true` TIL. Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `timeoutSignal` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change message when there's no server support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `slidingSyncHealthCheck` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `nativeSlidingSyncSupport` with try/catch Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change comment to hotlink Signed-off-by: Ed Geraghty <ed@geraghty.family> * Try and make the toggle disabled when there's no endpoint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the if statement outside the refactored fn to avoid an await Signed-off-by: Ed Geraghty <ed@geraghty.family> * Revert "Swap `configure` to private, we call it from `setup` which handles proxy" This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426. * Remove unused import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Further refactor `slidingSyncHealthCheck` `proxySlidingSyncSupport` already checks the client well-known is there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `proxySlidingSyncSupport` log on success Signed-off-by: Ed Geraghty <ed@geraghty.family> * Clarify log message for proxy being up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the logic into SlidingSyncManager All so we can set a static variable because the disabled check isn't asynchronous :) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Obviously this isn't a return so don't overwrite with false! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove outdated comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to pass in the client Signed-off-by: Ed Geraghty <ed@geraghty.family> * Activating SS should probably be info level logs Signed-off-by: Ed Geraghty <ed@geraghty.family> * If we've not enabled sliding sync, push the logs down a bit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update i18n error message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused i18n strings Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct log message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Prettier Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove many of the log messages Signed-off-by: Ed Geraghty <ed@geraghty.family> * Short out of `checkSupport` if it's `true` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add the endpoint back into the log when we're enabling it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Note in the comment that `feature_sliding_sync_proxy_url` is legacy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Expand the well-known liveness check log Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to stall the client waiting for sliding sync support * `AutoDiscovery.findClientConfig` throws if the baseUrl is blank * Fix `getProxyFromWellKnown` (?) * Add missing semicolon Sorry, linter! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pass our `MatrixClient` through instead of trying to grab it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing return in function comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * Actually pass through our Client, not the Peg object Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove SonarCube smell complaint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Neew to make our other two methods public to test Signed-off-by: Ed Geraghty <ed@geraghty.family> * First passing test Hurrah! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Two more tests, this time on `checkSupport` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Reset our `serverSupportsSlidingSync` between tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check the static member is being set Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the static assignation down to the relevant tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pull getProxyFromWellKnown mocking up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check we /haven't/ shorted out Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move our spy up so we can reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check spidering is being called Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test the proxy is declared Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test entered manually Signed-off-by: Ed Geraghty <ed@geraghty.family> * Sorry, linter * I guess these strings are wrong? * Replace any with string Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Ed Geraghty <ed@geraghty.family> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
*/
public async nativeSlidingSyncSupport(client: MatrixClient): Promise<boolean> {
// Per https://github.com/matrix-org/matrix-spec-proposals/pull/3575/files#r1589542561
// `client` can be undefined/null in tests for some reason.
const support = await client?.doesServerSupportUnstableFeature("org.matrix.msc3575");
if (support) {
logger.log("nativeSlidingSyncSupport: sliding sync advertised as unstable");
MSC3575 (Sliding Sync) add well-known proxy support (#12307) * Initial commit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove commented code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change function to reflect it's proxy not native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add check for servers with native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add native support check back in Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add endpoint health check function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Use inbuilt `getWellKnown` function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change the error message to the correct function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Stop storing the proxyurl in the settings for now Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logger messages more useful Signed-off-by: Ed Geraghty <ed@geraghty.family> * Start moving the checking logic directly into the controller Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Get the client rather than passing it in to the functions Signed-off-by: Ed Geraghty <ed@geraghty.family> * remove invalid `function` keyword Signed-off-by: Ed Geraghty <ed@geraghty.family> * Fix imports Signed-off-by: Ed Geraghty <ed@geraghty.family> * Our new functions are private We shouldn't(?) have to use these check in future elsewhere Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change our proxy check function to return a boolean Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `nativeSlidingSyncSupport` also return boolean, add in health check Signed-off-by: Ed Geraghty <ed@geraghty.family> * Disable the sliding sync option if the server doesn't support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only enable the setting if it passes (again) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update our comments to better match what's going on Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused dialog Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add a well-known check on start-up, if sliding sync has been enabled Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check against the correct endpoint... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Extract baseUrl as we'll reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logs differentiate between the types of proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Grab the client well-known directly for use Can't use the client object at this point, it hasn't read in the well-known Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add myself to the copyright assignation I wrote the majority of this file... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only return `true` if it's actually there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `proxySlidingSyncSupport` function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `nativeSlidingSyncSupport`function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Another comment/functionality paring Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove duplicated types from the doc Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move await to the previous line Removes brackets, and corrects `wellKnown` from being a `Promise` Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `waitForClientWellKnown` to avoid a race condition with the request Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move getting the client out of the `if`, use `waitForClientWellKnown` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove `beforeChange` override Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move proxy setup logic into `SlidingSyncManager` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Swap `configure` to private, we call it from `setup` which handles proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Promises are always `true` TIL. Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `timeoutSignal` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change message when there's no server support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `slidingSyncHealthCheck` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `nativeSlidingSyncSupport` with try/catch Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change comment to hotlink Signed-off-by: Ed Geraghty <ed@geraghty.family> * Try and make the toggle disabled when there's no endpoint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the if statement outside the refactored fn to avoid an await Signed-off-by: Ed Geraghty <ed@geraghty.family> * Revert "Swap `configure` to private, we call it from `setup` which handles proxy" This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426. * Remove unused import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Further refactor `slidingSyncHealthCheck` `proxySlidingSyncSupport` already checks the client well-known is there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `proxySlidingSyncSupport` log on success Signed-off-by: Ed Geraghty <ed@geraghty.family> * Clarify log message for proxy being up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the logic into SlidingSyncManager All so we can set a static variable because the disabled check isn't asynchronous :) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Obviously this isn't a return so don't overwrite with false! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove outdated comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to pass in the client Signed-off-by: Ed Geraghty <ed@geraghty.family> * Activating SS should probably be info level logs Signed-off-by: Ed Geraghty <ed@geraghty.family> * If we've not enabled sliding sync, push the logs down a bit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update i18n error message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused i18n strings Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct log message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Prettier Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove many of the log messages Signed-off-by: Ed Geraghty <ed@geraghty.family> * Short out of `checkSupport` if it's `true` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add the endpoint back into the log when we're enabling it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Note in the comment that `feature_sliding_sync_proxy_url` is legacy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Expand the well-known liveness check log Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to stall the client waiting for sliding sync support * `AutoDiscovery.findClientConfig` throws if the baseUrl is blank * Fix `getProxyFromWellKnown` (?) * Add missing semicolon Sorry, linter! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pass our `MatrixClient` through instead of trying to grab it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing return in function comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * Actually pass through our Client, not the Peg object Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove SonarCube smell complaint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Neew to make our other two methods public to test Signed-off-by: Ed Geraghty <ed@geraghty.family> * First passing test Hurrah! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Two more tests, this time on `checkSupport` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Reset our `serverSupportsSlidingSync` between tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check the static member is being set Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the static assignation down to the relevant tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pull getProxyFromWellKnown mocking up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check we /haven't/ shorted out Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move our spy up so we can reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check spidering is being called Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test the proxy is declared Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test entered manually Signed-off-by: Ed Geraghty <ed@geraghty.family> * Sorry, linter * I guess these strings are wrong? * Replace any with string Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Ed Geraghty <ed@geraghty.family> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
}
return support;
MSC3575 (Sliding Sync) add well-known proxy support (#12307) * Initial commit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove commented code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change function to reflect it's proxy not native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add check for servers with native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add native support check back in Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add endpoint health check function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Use inbuilt `getWellKnown` function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change the error message to the correct function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Stop storing the proxyurl in the settings for now Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logger messages more useful Signed-off-by: Ed Geraghty <ed@geraghty.family> * Start moving the checking logic directly into the controller Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Get the client rather than passing it in to the functions Signed-off-by: Ed Geraghty <ed@geraghty.family> * remove invalid `function` keyword Signed-off-by: Ed Geraghty <ed@geraghty.family> * Fix imports Signed-off-by: Ed Geraghty <ed@geraghty.family> * Our new functions are private We shouldn't(?) have to use these check in future elsewhere Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change our proxy check function to return a boolean Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `nativeSlidingSyncSupport` also return boolean, add in health check Signed-off-by: Ed Geraghty <ed@geraghty.family> * Disable the sliding sync option if the server doesn't support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only enable the setting if it passes (again) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update our comments to better match what's going on Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused dialog Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add a well-known check on start-up, if sliding sync has been enabled Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check against the correct endpoint... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Extract baseUrl as we'll reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logs differentiate between the types of proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Grab the client well-known directly for use Can't use the client object at this point, it hasn't read in the well-known Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add myself to the copyright assignation I wrote the majority of this file... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only return `true` if it's actually there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `proxySlidingSyncSupport` function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `nativeSlidingSyncSupport`function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Another comment/functionality paring Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove duplicated types from the doc Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move await to the previous line Removes brackets, and corrects `wellKnown` from being a `Promise` Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `waitForClientWellKnown` to avoid a race condition with the request Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move getting the client out of the `if`, use `waitForClientWellKnown` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove `beforeChange` override Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move proxy setup logic into `SlidingSyncManager` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Swap `configure` to private, we call it from `setup` which handles proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Promises are always `true` TIL. Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `timeoutSignal` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change message when there's no server support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `slidingSyncHealthCheck` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `nativeSlidingSyncSupport` with try/catch Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change comment to hotlink Signed-off-by: Ed Geraghty <ed@geraghty.family> * Try and make the toggle disabled when there's no endpoint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the if statement outside the refactored fn to avoid an await Signed-off-by: Ed Geraghty <ed@geraghty.family> * Revert "Swap `configure` to private, we call it from `setup` which handles proxy" This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426. * Remove unused import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Further refactor `slidingSyncHealthCheck` `proxySlidingSyncSupport` already checks the client well-known is there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `proxySlidingSyncSupport` log on success Signed-off-by: Ed Geraghty <ed@geraghty.family> * Clarify log message for proxy being up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the logic into SlidingSyncManager All so we can set a static variable because the disabled check isn't asynchronous :) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Obviously this isn't a return so don't overwrite with false! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove outdated comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to pass in the client Signed-off-by: Ed Geraghty <ed@geraghty.family> * Activating SS should probably be info level logs Signed-off-by: Ed Geraghty <ed@geraghty.family> * If we've not enabled sliding sync, push the logs down a bit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update i18n error message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused i18n strings Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct log message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Prettier Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove many of the log messages Signed-off-by: Ed Geraghty <ed@geraghty.family> * Short out of `checkSupport` if it's `true` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add the endpoint back into the log when we're enabling it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Note in the comment that `feature_sliding_sync_proxy_url` is legacy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Expand the well-known liveness check log Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to stall the client waiting for sliding sync support * `AutoDiscovery.findClientConfig` throws if the baseUrl is blank * Fix `getProxyFromWellKnown` (?) * Add missing semicolon Sorry, linter! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pass our `MatrixClient` through instead of trying to grab it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing return in function comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * Actually pass through our Client, not the Peg object Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove SonarCube smell complaint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Neew to make our other two methods public to test Signed-off-by: Ed Geraghty <ed@geraghty.family> * First passing test Hurrah! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Two more tests, this time on `checkSupport` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Reset our `serverSupportsSlidingSync` between tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check the static member is being set Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the static assignation down to the relevant tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pull getProxyFromWellKnown mocking up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check we /haven't/ shorted out Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move our spy up so we can reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check spidering is being called Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test the proxy is declared Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test entered manually Signed-off-by: Ed Geraghty <ed@geraghty.family> * Sorry, linter * I guess these strings are wrong? * Replace any with string Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Ed Geraghty <ed@geraghty.family> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
}
/**
* Check whether our homeserver has sliding sync support, that the endpoint is up, and
* is a sliding sync endpoint.
*
* Sets static member `SlidingSyncController.serverSupportsSlidingSync`
* @param client The MatrixClient to use
*/
public async checkSupport(client: MatrixClient): Promise<void> {
if (await this.nativeSlidingSyncSupport(client)) {
SlidingSyncController.serverSupportsSlidingSync = true;
return;
}
const proxyUrl = await this.getProxyFromWellKnown(client);
if (proxyUrl != undefined) {
const response = await fetch(new URL("/client/server.json", proxyUrl), {
MSC3575 (Sliding Sync) add well-known proxy support (#12307) * Initial commit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove commented code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change function to reflect it's proxy not native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add check for servers with native support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add native support check back in Signed-off-by: Ed Geraghty <ed@geraghty.family> * Re-add endpoint health check function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Use inbuilt `getWellKnown` function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change the error message to the correct function Signed-off-by: Ed Geraghty <ed@geraghty.family> * Stop storing the proxyurl in the settings for now Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logger messages more useful Signed-off-by: Ed Geraghty <ed@geraghty.family> * Start moving the checking logic directly into the controller Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Get the client rather than passing it in to the functions Signed-off-by: Ed Geraghty <ed@geraghty.family> * remove invalid `function` keyword Signed-off-by: Ed Geraghty <ed@geraghty.family> * Fix imports Signed-off-by: Ed Geraghty <ed@geraghty.family> * Our new functions are private We shouldn't(?) have to use these check in future elsewhere Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change our proxy check function to return a boolean Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `nativeSlidingSyncSupport` also return boolean, add in health check Signed-off-by: Ed Geraghty <ed@geraghty.family> * Disable the sliding sync option if the server doesn't support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only enable the setting if it passes (again) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update our comments to better match what's going on Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused dialog Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add a well-known check on start-up, if sliding sync has been enabled Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check against the correct endpoint... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Extract baseUrl as we'll reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make the logs differentiate between the types of proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Grab the client well-known directly for use Can't use the client object at this point, it hasn't read in the well-known Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add myself to the copyright assignation I wrote the majority of this file... Signed-off-by: Ed Geraghty <ed@geraghty.family> * Only return `true` if it's actually there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `proxySlidingSyncSupport` function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct the `nativeSlidingSyncSupport`function comment to match the code Signed-off-by: Ed Geraghty <ed@geraghty.family> * Another comment/functionality paring Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove duplicated types from the doc Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move await to the previous line Removes brackets, and corrects `wellKnown` from being a `Promise` Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `waitForClientWellKnown` to avoid a race condition with the request Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move getting the client out of the `if`, use `waitForClientWellKnown` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove `beforeChange` override Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move proxy setup logic into `SlidingSyncManager` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Swap `configure` to private, we call it from `setup` which handles proxy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Promises are always `true` TIL. Signed-off-by: Ed Geraghty <ed@geraghty.family> * use `timeoutSignal` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change message when there's no server support Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `slidingSyncHealthCheck` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Refactor `nativeSlidingSyncSupport` with try/catch Signed-off-by: Ed Geraghty <ed@geraghty.family> * Change comment to hotlink Signed-off-by: Ed Geraghty <ed@geraghty.family> * Try and make the toggle disabled when there's no endpoint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the if statement outside the refactored fn to avoid an await Signed-off-by: Ed Geraghty <ed@geraghty.family> * Revert "Swap `configure` to private, we call it from `setup` which handles proxy" This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426. * Remove unused import Signed-off-by: Ed Geraghty <ed@geraghty.family> * Further refactor `slidingSyncHealthCheck` `proxySlidingSyncSupport` already checks the client well-known is there Signed-off-by: Ed Geraghty <ed@geraghty.family> * Make `proxySlidingSyncSupport` log on success Signed-off-by: Ed Geraghty <ed@geraghty.family> * Clarify log message for proxy being up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the logic into SlidingSyncManager All so we can set a static variable because the disabled check isn't asynchronous :) Signed-off-by: Ed Geraghty <ed@geraghty.family> * Obviously this isn't a return so don't overwrite with false! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove outdated comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to pass in the client Signed-off-by: Ed Geraghty <ed@geraghty.family> * Activating SS should probably be info level logs Signed-off-by: Ed Geraghty <ed@geraghty.family> * If we've not enabled sliding sync, push the logs down a bit Signed-off-by: Ed Geraghty <ed@geraghty.family> * Update i18n error message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove unused i18n strings Signed-off-by: Ed Geraghty <ed@geraghty.family> * Correct log message Signed-off-by: Ed Geraghty <ed@geraghty.family> * Prettier Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove many of the log messages Signed-off-by: Ed Geraghty <ed@geraghty.family> * Short out of `checkSupport` if it's `true` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add the endpoint back into the log when we're enabling it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Note in the comment that `feature_sliding_sync_proxy_url` is legacy Signed-off-by: Ed Geraghty <ed@geraghty.family> * Expand the well-known liveness check log Signed-off-by: Ed Geraghty <ed@geraghty.family> * No need to stall the client waiting for sliding sync support * `AutoDiscovery.findClientConfig` throws if the baseUrl is blank * Fix `getProxyFromWellKnown` (?) * Add missing semicolon Sorry, linter! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pass our `MatrixClient` through instead of trying to grab it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Add missing return in function comment Signed-off-by: Ed Geraghty <ed@geraghty.family> * Actually pass through our Client, not the Peg object Signed-off-by: Ed Geraghty <ed@geraghty.family> * Remove SonarCube smell complaint Signed-off-by: Ed Geraghty <ed@geraghty.family> * Neew to make our other two methods public to test Signed-off-by: Ed Geraghty <ed@geraghty.family> * First passing test Hurrah! Signed-off-by: Ed Geraghty <ed@geraghty.family> * Two more tests, this time on `checkSupport` Signed-off-by: Ed Geraghty <ed@geraghty.family> * Reset our `serverSupportsSlidingSync` between tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check the static member is being set Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move the static assignation down to the relevant tests Signed-off-by: Ed Geraghty <ed@geraghty.family> * Pull getProxyFromWellKnown mocking up Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check we /haven't/ shorted out Signed-off-by: Ed Geraghty <ed@geraghty.family> * Move our spy up so we can reuse it Signed-off-by: Ed Geraghty <ed@geraghty.family> * Check spidering is being called Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test the proxy is declared Signed-off-by: Ed Geraghty <ed@geraghty.family> * Test entered manually Signed-off-by: Ed Geraghty <ed@geraghty.family> * Sorry, linter * I guess these strings are wrong? * Replace any with string Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Ed Geraghty <ed@geraghty.family> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
method: Method.Get,
signal: timeoutSignal(10 * 1000), // 10s
});
if (response.status === 200) {
logger.log("checkSupport: well-known sliding sync proxy is up at", proxyUrl);
SlidingSyncController.serverSupportsSlidingSync = true;
}
}
}
Implement MSC3575: Sliding Sync (#8328) * Add labs flag for sliding sync; add sliding_sync_proxy_url to config.json * Disable the labs toggle if sliding_sync_proxy_url is not set * Do validation checks on the sliding sync proxy URL before enabling it in Labs * Enable sliding sync and add SlidingSyncManager * Get room subscriptions working * Hijack renderSublists in sliding sync mode * Add support for sorting alphabetically/recency and room name filters * Filter out tombstoned rooms; start adding show more logic list ranges update but the UI doesn't * update the UI when the list is updated * bugfix: make sure the list sorts numerically * Get invites transitioning correctly * Force enable sliding sync and labs for now * Linting * Disable spotlight search * Initial cypress plugins for Sliding Sync Proxy * Use --rm when running Synapse in Docker for Cypress tests * Update src/MatrixClientPeg.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/settings/controllers/SlidingSyncController.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Travis Ralston <travisr@matrix.org> * WIP add room searching to spotlight search * Only read sliding sync results when there is a result, else use the local cache * Use feature_sliding_sync not slidingSync * Some review comments * More review comments * Use RoomViewStore to set room subscriptions * Comment why any * Update src/components/views/rooms/RoomSublist.tsx Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * Fix cypress docker abstraction * Iterate sliding sync proxy support * Stash mostly functional test * Update sliding sync proxy image * i18n * Add support for spaces; use list ID -> index mappings - Mappings are more reusable and easier to understand than racing for index positions. - Register for all spaces immediately on startup. * When the active space is updated, update the list registration * Set spaces filter in the correct place * Skeleton placeholder whilst loading the space * Filter out spaces from the room list * Use the new txn_id promises * Ensure we actually resolve list registrations * Fix matrix-org/sliding-sync#30: don't show tombstoned search results * Remove unused imports * Add SYNCV3_SECRET to proxy to ensure it starts up; correct aliases for SS test * Add another basic sliding sync e2e test * Unbreak netlify * Add more logging for debugging duplicate rooms * If sliding sync is enabled, always use the rooms result even if it's empty * Drop-in copy of RoomListStore for sliding sync * Remove conditionals from RoomListStore - we have SlidingRoomListStore now * WIP SlidingRoomListStore * Add most sliding sync logic to SlidingRoomListStore Still lots of logic in RoomSublist. Broken things: - Join count is wrong completely. - No skeleton placeholder when switching spaces. * Migrate joined count to SS RLS * Reinstate the skeleton UI when the list is loading * linting * Add support for sticky rooms based on the currently active room * Add a bunch of passing SS E2E tests; some WIP * Unbreak build from git merge * Suppress unread indicators in sliding sync mode * Add regression test for https://github.com/matrix-org/sliding-sync/issues/28 * Add invite test flows; show the invite list The refactor to SS RLS removed the invite list entirely. * Remove show more click as it wasn't the bug * Linting and i18n * only enable SS by default on netlify * Jest fixes; merge conflict fixes; remove debug logging; use right sort enum values * Actually fix jest tests * Add support for favourites and low priority * Bump sliding sync version * Update sliding sync labs to be user configurable * delint * To disable SS or change proxy URL the user has to log out * Review comments * Linting * Apply suggestions from code review Co-authored-by: Travis Ralston <travisr@matrix.org> * Update src/stores/room-list/SlidingRoomListStore.ts Co-authored-by: Travis Ralston <travisr@matrix.org> * Review comments * Add issue link for TODO markers * Linting * Apply suggestions from code review Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * More review comments * More review comments * stricter types Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Travis Ralston <travisr@matrix.org>
2022-09-07 23:42:39 +08:00
}