You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
support paginating relations
This commit is contained in:
@@ -440,14 +440,20 @@ MatrixBaseApis.prototype.createRoom = function(options, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
MatrixBaseApis.prototype.fetchRelations =
|
MatrixBaseApis.prototype.fetchRelations =
|
||||||
async function(roomId, eventId, relationType, eventType) {
|
async function(roomId, eventId, relationType, eventType, opts) {
|
||||||
|
const queryParams = {};
|
||||||
|
if (opts.token) {
|
||||||
|
queryParams.from = opts.token;
|
||||||
|
}
|
||||||
|
const queryString = utils.encodeParams(queryParams);
|
||||||
// valid options include: room_alias_name, visibility, invite
|
// valid options include: room_alias_name, visibility, invite
|
||||||
const response = await this._http.authedRequestWithPrefix(
|
const response = await this._http.authedRequestWithPrefix(
|
||||||
undefined,
|
undefined,
|
||||||
"GET", `/rooms/${roomId}/relations/${eventId}/${relationType}/${eventType}`,
|
"GET",
|
||||||
|
`/rooms/${roomId}/relations/${eventId}/${relationType}/${eventType}?` + queryString,
|
||||||
null, null, httpApi.PREFIX_UNSTABLE,
|
null, null, httpApi.PREFIX_UNSTABLE,
|
||||||
);
|
);
|
||||||
return response.chunk;
|
return response;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3966,9 +3966,17 @@ MatrixClient.prototype.getCanResetTimelineCallback = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
MatrixClient.prototype.relations =
|
MatrixClient.prototype.relations =
|
||||||
async function(roomId, eventId, relationType, eventType) {
|
async function(roomId, eventId, relationType, eventType, opts = {}) {
|
||||||
const events = await this.fetchRelations(roomId, eventId, relationType, eventType);
|
const result = await this.fetchRelations(
|
||||||
return events.map(this.getEventMapper());
|
roomId,
|
||||||
|
eventId,
|
||||||
|
relationType,
|
||||||
|
eventType,
|
||||||
|
opts);
|
||||||
|
return {
|
||||||
|
events: result.chunk.map(this.getEventMapper()),
|
||||||
|
nextBatch: result.next_batch,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
function setupCallEventHandler(client) {
|
function setupCallEventHandler(client) {
|
||||||
|
|||||||
Reference in New Issue
Block a user