handle accountData changes, and errors on toggling URL previews

pull/21833/head
Matthew Hodgson 2016-07-20 18:14:16 +01:00
parent 9babf3f92f
commit d6415aceca
2 changed files with 9 additions and 2 deletions

View File

@ -120,7 +120,7 @@ module.exports = {
setUrlPreviewsDisabled: function(disabled) {
// FIXME: handle errors
MatrixClientPeg.get().setAccountData("org.matrix.preview_urls", {
return MatrixClientPeg.get().setAccountData("org.matrix.preview_urls", {
disable: disabled
});
},
@ -139,7 +139,7 @@ module.exports = {
var settings = this.getSyncedSettings();
settings[type] = value;
// FIXME: handle errors
MatrixClientPeg.get().setAccountData("im.vector.web.settings", settings);
return MatrixClientPeg.get().setAccountData("im.vector.web.settings", settings);
},
isFeatureEnabled: function(feature: string): boolean {

View File

@ -138,6 +138,7 @@ module.exports = React.createClass({
MatrixClientPeg.get().on("Room.timeline", this.onRoomTimeline);
MatrixClientPeg.get().on("Room.accountData", this.onRoomAccountData);
MatrixClientPeg.get().on("RoomState.members", this.onRoomStateMember);
MatrixClientPeg.get().on("accountData", this.onAccountData);
this.tabComplete = new TabComplete({
allowLooping: false,
@ -460,6 +461,12 @@ module.exports = React.createClass({
Tinter.tint(color_scheme.primary_color, color_scheme.secondary_color);
},
onAccountData: function(event) {
if (event.getType() === "org.matrix.preview_urls" && this.state.room) {
this._updatePreviewUrlVisibility(this.state.room);
}
},
onRoomAccountData: function(event, room) {
if (room.roomId == this.state.roomId) {
if (event.getType() === "org.matrix.room.color_scheme") {