You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-18 05:42:00 +03:00
fix some review feedback; add initial api for setting & deleting tags; still a WIP
This commit is contained in:
@@ -608,6 +608,43 @@ MatrixClient.prototype.setRoomTopic = function(roomId, topic, callback) {
|
||||
undefined, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} roomId
|
||||
* @param {string} name of room tag to be set
|
||||
* @param {object} metadata associated with that tag to be stored
|
||||
* @param {module:client.callback} callback Optional.
|
||||
* @return {module:client.Promise} Resolves: TODO
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
MatrixClient.prototype.setRoomTag = function(roomId, tagName, metadata, callback) {
|
||||
var path = utils.encodeUri("/user/$userId/rooms/$roomId/tags/$tag", {
|
||||
$userId: this.credentials.userId,
|
||||
$roomId: roomId,
|
||||
$tag: tagName,
|
||||
});
|
||||
return this._http.authedRequestWithPrefix(
|
||||
callback, "PUT", path, undefined, metadata, httpApi.PREFIX_V2_ALPHA
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} roomId
|
||||
* @param {string} name of room tag to be removed
|
||||
* @param {module:client.callback} callback Optional.
|
||||
* @return {module:client.Promise} Resolves: TODO
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
MatrixClient.prototype.deleteRoomTag = function(roomId, tagName, callback) {
|
||||
var path = utils.encodeUri("/user/$userId/rooms/$roomId/tags/$tag", {
|
||||
$userId: this.credentials.userId,
|
||||
$roomId: roomId,
|
||||
$tag: tagName,
|
||||
});
|
||||
return this._http.authedRequestWithPrefix(
|
||||
callback, "DELETE", path, undefined, undefined, httpApi.PREFIX_V2_ALPHA
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a user's power level.
|
||||
* @param {string} roomId
|
||||
@@ -1945,7 +1982,7 @@ function doInitialSync(client, historyLen, includeArchived) {
|
||||
var privateUserData = data.rooms[i].private_user_data || [];
|
||||
for (j = 0; j < privateUserData.length; j++) {
|
||||
var event = _PojoToMatrixEventMapper(client)(privateUserData[j]);
|
||||
if (event.type === "m.tag") {
|
||||
if (event.getType() === "m.tag") {
|
||||
room.addTags(event);
|
||||
}
|
||||
// XXX: unhandled private user data event - we should probably
|
||||
|
@@ -423,12 +423,12 @@ Room.prototype.addTags = function(event) {
|
||||
// }
|
||||
// }
|
||||
|
||||
// XXX: do we need to deep copy here?
|
||||
this.tags = event.getContent().tags;
|
||||
|
||||
// XXX: we could do a deep-comparison to see if the tags have really
|
||||
// changed - but do we want to bother?
|
||||
this.emit("Room.tags", this);
|
||||
|
||||
// XXX: do we need to deep copy here?
|
||||
this.tags = event.content.tags;
|
||||
};
|
||||
|
||||
function setEventMetadata(event, stateContext, toStartOfTimeline) {
|
||||
|
Reference in New Issue
Block a user