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
rename target id to related id and add jsdoc comments
This commit is contained in:
@@ -1730,11 +1730,11 @@ MatrixClient.prototype._sendCompleteEvent = function(roomId, eventObject, txnId,
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const room = this.getRoom(roomId);
|
const room = this.getRoom(roomId);
|
||||||
const targetId = localEvent.getTargetId();
|
const targetId = localEvent.getRelatedId();
|
||||||
if (targetId && targetId.startsWith("~")) {
|
if (targetId && targetId.startsWith("~")) {
|
||||||
const target = room.getPendingEvents().find(e => e.getId() === targetId);
|
const target = room.getPendingEvents().find(e => e.getId() === targetId);
|
||||||
target.once("Event.localEventIdReplaced", () => {
|
target.once("Event.localEventIdReplaced", () => {
|
||||||
localEvent.updateTargetId(target.getId());
|
localEvent.updateRelatedId(target.getId());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const type = localEvent.getType();
|
const type = localEvent.getType();
|
||||||
|
|||||||
@@ -881,8 +881,12 @@ utils.extend(module.exports.MatrixEvent.prototype, {
|
|||||||
return this._replacingEvent;
|
return this._replacingEvent;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
getTargetId() {
|
* For relations and redactions, returns the event_id this event is referring to.
|
||||||
|
*
|
||||||
|
* @return {string?}
|
||||||
|
*/
|
||||||
|
getRelatedId() {
|
||||||
const relation = this.getRelation();
|
const relation = this.getRelation();
|
||||||
if (relation) {
|
if (relation) {
|
||||||
return relation.event_id;
|
return relation.event_id;
|
||||||
@@ -891,7 +895,15 @@ utils.extend(module.exports.MatrixEvent.prototype, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTargetId(eventId) {
|
/**
|
||||||
|
* Update the related id with a new one.
|
||||||
|
*
|
||||||
|
* Used to replace a local id with remote one before sending
|
||||||
|
* an event with a related id.
|
||||||
|
*
|
||||||
|
* @param {string} eventId the new event id
|
||||||
|
*/
|
||||||
|
updateRelatedId(eventId) {
|
||||||
const relation = this.getRelation();
|
const relation = this.getRelation();
|
||||||
if (relation) {
|
if (relation) {
|
||||||
relation.event_id = eventId;
|
relation.event_id = eventId;
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ MatrixScheduler.RETRY_BACKOFF_RATELIMIT = function(event, attempts, err) {
|
|||||||
* @see module:scheduler~queueAlgorithm
|
* @see module:scheduler~queueAlgorithm
|
||||||
*/
|
*/
|
||||||
MatrixScheduler.QUEUE_MESSAGES = function(event) {
|
MatrixScheduler.QUEUE_MESSAGES = function(event) {
|
||||||
if (event.getType() === "m.room.message" || !!event.getTargetId()) {
|
if (event.getType() === "m.room.message" || !!event.getRelatedId()) {
|
||||||
// put these events in the 'message' queue.
|
// put these events in the 'message' queue.
|
||||||
return "message";
|
return "message";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user