handle accountData changes, and errors on toggling URL previews

This commit is contained in:
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) { setUrlPreviewsDisabled: function(disabled) {
// FIXME: handle errors // FIXME: handle errors
MatrixClientPeg.get().setAccountData("org.matrix.preview_urls", { return MatrixClientPeg.get().setAccountData("org.matrix.preview_urls", {
disable: disabled disable: disabled
}); });
}, },
@ -139,7 +139,7 @@ module.exports = {
var settings = this.getSyncedSettings(); var settings = this.getSyncedSettings();
settings[type] = value; settings[type] = value;
// FIXME: handle errors // 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 { 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.timeline", this.onRoomTimeline);
MatrixClientPeg.get().on("Room.accountData", this.onRoomAccountData); MatrixClientPeg.get().on("Room.accountData", this.onRoomAccountData);
MatrixClientPeg.get().on("RoomState.members", this.onRoomStateMember); MatrixClientPeg.get().on("RoomState.members", this.onRoomStateMember);
MatrixClientPeg.get().on("accountData", this.onAccountData);
this.tabComplete = new TabComplete({ this.tabComplete = new TabComplete({
allowLooping: false, allowLooping: false,
@ -460,6 +461,12 @@ module.exports = React.createClass({
Tinter.tint(color_scheme.primary_color, color_scheme.secondary_color); 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) { onRoomAccountData: function(event, room) {
if (room.roomId == this.state.roomId) { if (room.roomId == this.state.roomId) {
if (event.getType() === "org.matrix.room.color_scheme") { if (event.getType() === "org.matrix.room.color_scheme") {