You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Move LL filter creation inside MatrixClient
As we need an option to turn lazy loading on (we can't just accept a filter, as /messages has an incompatible filter), better only pass the option and create the filter inside startClient
This commit is contained in:
@@ -45,6 +45,18 @@ const ContentHelpers = require("./content-helpers");
|
|||||||
import ReEmitter from './ReEmitter';
|
import ReEmitter from './ReEmitter';
|
||||||
import RoomList from './crypto/RoomList';
|
import RoomList from './crypto/RoomList';
|
||||||
|
|
||||||
|
|
||||||
|
const LAZY_LOADING_MESSAGES_FILTER = {
|
||||||
|
lazy_load_members: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const LAZY_LOADING_SYNC_FILTER = {
|
||||||
|
room: {
|
||||||
|
state: LAZY_LOADING_MESSAGES_FILTER,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const SCROLLBACK_DELAY_MS = 3000;
|
const SCROLLBACK_DELAY_MS = 3000;
|
||||||
let CRYPTO_ENABLED = false;
|
let CRYPTO_ENABLED = false;
|
||||||
|
|
||||||
@@ -2115,7 +2127,7 @@ MatrixClient.prototype._createMessagesRequest = function(roomId, fromToken, limi
|
|||||||
|
|
||||||
let filter = null;
|
let filter = null;
|
||||||
if (this._clientOpts.lazyLoadMembers) {
|
if (this._clientOpts.lazyLoadMembers) {
|
||||||
filter = {lazy_load_members: true};
|
filter = LAZY_LOADING_MESSAGES_FILTER;
|
||||||
}
|
}
|
||||||
if (timelineFilter) {
|
if (timelineFilter) {
|
||||||
// XXX: it's horrific that /messages' filter parameter doesn't match
|
// XXX: it's horrific that /messages' filter parameter doesn't match
|
||||||
@@ -3041,8 +3053,9 @@ MatrixClient.prototype.getTurnServers = function() {
|
|||||||
* updating presence.
|
* updating presence.
|
||||||
* @param {Boolean=} opts.lazyLoadMembers True to not load all membership events during
|
* @param {Boolean=} opts.lazyLoadMembers True to not load all membership events during
|
||||||
* initial sync but fetch them when needed by calling `loadOutOfBandMembers`
|
* initial sync but fetch them when needed by calling `loadOutOfBandMembers`
|
||||||
|
* This will override the filter option at this moment.
|
||||||
*/
|
*/
|
||||||
MatrixClient.prototype.startClient = function(opts) {
|
MatrixClient.prototype.startClient = async function(opts) {
|
||||||
if (this.clientRunning) {
|
if (this.clientRunning) {
|
||||||
// client is already running.
|
// client is already running.
|
||||||
return;
|
return;
|
||||||
@@ -3072,6 +3085,10 @@ MatrixClient.prototype.startClient = function(opts) {
|
|||||||
// shallow-copy the opts dict before modifying and storing it
|
// shallow-copy the opts dict before modifying and storing it
|
||||||
opts = Object.assign({}, opts);
|
opts = Object.assign({}, opts);
|
||||||
|
|
||||||
|
if (opts.lazyLoadMembers) {
|
||||||
|
opts.filter = await this.createFilter(LAZY_LOADING_SYNC_FILTER);
|
||||||
|
}
|
||||||
|
|
||||||
opts.crypto = this._crypto;
|
opts.crypto = this._crypto;
|
||||||
opts.canResetEntireTimeline = (roomId) => {
|
opts.canResetEntireTimeline = (roomId) => {
|
||||||
if (!this._canResetTimelineCallback) {
|
if (!this._canResetTimelineCallback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user