From d6415aceca539a8c084ba4932864a532e129fe7d Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 20 Jul 2016 18:14:16 +0100 Subject: [PATCH] handle accountData changes, and errors on toggling URL previews --- src/UserSettingsStore.js | 4 ++-- src/components/structures/RoomView.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/UserSettingsStore.js b/src/UserSettingsStore.js index 39f393b242..f4eb4f0d83 100644 --- a/src/UserSettingsStore.js +++ b/src/UserSettingsStore.js @@ -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 { diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index f73b90ae28..cef85931e1 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -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") {