1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-01 04:43:29 +03:00

Add ability to set a filter prior to initial sync.

Useful for only syncing with a subset of joined rooms or only retrieving certain relevant types of events.
This commit is contained in:
lukebarnard
2016-10-25 20:05:25 +01:00
parent d105854619
commit 5900542cfb
2 changed files with 10 additions and 2 deletions

View File

@@ -2511,6 +2511,9 @@ MatrixClient.prototype.getTurnServers = function() {
* *
* @param {Number=} opts.pollTimeout The number of milliseconds to wait on /events. * @param {Number=} opts.pollTimeout The number of milliseconds to wait on /events.
* Default: 30000 (30 seconds). * Default: 30000 (30 seconds).
*
* @param {Filter=} opts.filter The filter to apply to /sync calls. This will override
* the opts.initialSyncLimit, which would normally result in a timeline limit filter.
*/ */
MatrixClient.prototype.startClient = function(opts) { MatrixClient.prototype.startClient = function(opts) {
if (this.clientRunning) { if (this.clientRunning) {

View File

@@ -391,8 +391,13 @@ SyncApi.prototype.sync = function() {
} }
function getFilter() { function getFilter() {
var filter = new Filter(client.credentials.userId); var filter;
if (self.opts.filter) {
filter = self.opts.filter;
} else {
filter = new Filter(client.credentials.userId);
filter.setTimelineLimit(self.opts.initialSyncLimit); filter.setTimelineLimit(self.opts.initialSyncLimit);
}
client.getOrCreateFilter( client.getOrCreateFilter(
getFilterName(client.credentials.userId), filter getFilterName(client.credentials.userId), filter