diff --git a/src/UserSettingsStore.js b/src/UserSettingsStore.js index 990fa8b7a9..39f393b242 100644 --- a/src/UserSettingsStore.js +++ b/src/UserSettingsStore.js @@ -115,7 +115,7 @@ module.exports = { getUrlPreviewsDisabled: function() { var event = MatrixClientPeg.get().getAccountData("org.matrix.preview_urls"); - return (event && event.disable); + return (event && event.getContent().disable); }, setUrlPreviewsDisabled: function(disabled) { @@ -126,7 +126,8 @@ module.exports = { }, getSyncedSettings: function() { - return MatrixClientPeg.get().getAccountData("im.vector.web.settings") || {}; + var event = MatrixClientPeg.get().getAccountData("im.vector.web.settings"); + return event ? event.getContent() : {}; }, getSyncedSetting: function(type) { diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index ea73193b03..7b5b3f7c7f 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -239,8 +239,6 @@ module.exports = React.createClass({ MatrixClientPeg.get().stopPeeking(); this._onRoomLoaded(this.state.room); } - - this._updatePreviewUrlVisibility(this.state.room); }, shouldComponentUpdate: function(nextProps, nextState) { @@ -372,6 +370,7 @@ module.exports = React.createClass({ // after a successful peek, or after we join the room). _onRoomLoaded: function(room) { this._calculatePeekRules(room); + this._updatePreviewUrlVisibility(room); }, _calculatePeekRules: function(room) { @@ -391,18 +390,20 @@ module.exports = React.createClass({ }, _updatePreviewUrlVisibility: function(room) { + console.log("_updatePreviewUrlVisibility"); + // check our per-room overrides var roomPreviewUrls = room.getAccountData("org.matrix.room.preview_urls"); - if (roomPreviewUrls && roomPreviewUrls.disabled !== undefined) { + if (roomPreviewUrls && roomPreviewUrls.getContent().disable !== undefined) { this.setState({ - showUrlPreview: !roomPreviewUrls.disabled + showUrlPreview: !roomPreviewUrls.getContent().disable }); return; } // check our global disable override - var userRoomPreviewUrls = MatrixClientPeg().get().getAccountData("org.matrix.preview_urls"); - if (userRoomPreviewUrls && userRoomPreviewUrls.disabled) { + var userRoomPreviewUrls = MatrixClientPeg.get().getAccountData("org.matrix.preview_urls"); + if (userRoomPreviewUrls && userRoomPreviewUrls.getContent().disable) { this.setState({ showUrlPreview: false }); @@ -411,7 +412,7 @@ module.exports = React.createClass({ // check the room state event var roomStatePreviewUrls = room.currentState.getStateEvents('org.matrix.room.preview_urls', ''); - if (roomStatePreviewUrls && roomStatePreviewUrls.disabled) { + if (roomStatePreviewUrls && roomStatePreviewUrls.getContent().disable) { this.setState({ showUrlPreview: false }); @@ -454,8 +455,8 @@ module.exports = React.createClass({ Tinter.tint(color_scheme.primary_color, color_scheme.secondary_color); }, - onRoomAccountData: function(room, event) { - if (room.roomId == this.props.roomId) { + onRoomAccountData: function(event, room) { + if (room.roomId == this.state.roomId) { if (event.getType() === "org.matrix.room.color_scheme") { var color_scheme = event.getContent(); // XXX: we should validate the event @@ -463,7 +464,7 @@ module.exports = React.createClass({ Tinter.tint(color_scheme.primary_color, color_scheme.secondary_color); } else if (event.getType() === "org.matrix.room.preview_urls") { - _updatePreviewUrlVisibility(room); + this._updatePreviewUrlVisibility(room); } } }, @@ -1557,6 +1558,8 @@ module.exports = React.createClass({ hideMessagePanel = true; } + console.log("ShowUrlPreview for %s is %s", this.state.room.roomId, this.state.showUrlPreview); + var messagePanel = ( { @@ -74,19 +98,6 @@ module.exports = React.createClass({ } } } - - if (this.props.mxEvent.getContent().format === "org.matrix.custom.html") - HtmlUtils.highlightDom(ReactDOM.findDOMNode(this)); - }, - - shouldComponentUpdate: function(nextProps, nextState) { - // exploit that events are immutable :) - // ...and that .links is only ever set in componentDidMount and never changes - return (nextProps.mxEvent.getId() !== this.props.mxEvent.getId() || - nextProps.highlights !== this.props.highlights || - nextProps.highlightLink !== this.props.highlightLink || - nextState.links !== this.state.links || - nextState.widgetHidden !== this.state.widgetHidden); }, findLinks: function(nodes) { @@ -175,7 +186,7 @@ module.exports = React.createClass({ } var widgets; - if (this.state.links.length && !this.state.widgetHidden) { + if (this.state.links.length && !this.state.widgetHidden && this.props.showUrlPreview) { var LinkPreviewWidget = sdk.getComponent('rooms.LinkPreviewWidget'); widgets = this.state.links.map((link)=>{ return + + Disable URL previews by default for participants in this room + + } + else { + disableRoomPreviewUrls = + + } + + return ( +
+

URL Previews

+ + + { disableRoomPreviewUrls } + + +
+ ); + + } +}); \ No newline at end of file diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index a914d513ac..77be8226a2 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -362,6 +362,8 @@ module.exports = React.createClass({ var SenderProfile = sdk.getComponent('messages.SenderProfile'); var MemberAvatar = sdk.getComponent('avatars.MemberAvatar'); + //console.log("EventTile showUrlPreview for %s is %s", this.props.mxEvent.getId(), this.props.showUrlPreview); + var content = this.props.mxEvent.getContent(); var msgtype = content.msgtype; diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index ee8b716e02..fda29a38f0 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -211,10 +211,13 @@ module.exports = React.createClass({ // color scheme promises.push(this.saveColor()); + // url preview settings + promises.push(this.saveUrlPreviewSettings()); + // encryption promises.push(this.saveEncryption()); - console.log("Performing %s operations", promises.length); + console.log("Performing %s operations: %s", promises.length, JSON.stringify(promises)); return q.allSettled(promises); }, @@ -228,6 +231,11 @@ module.exports = React.createClass({ return this.refs.color_settings.saveSettings(); }, + saveUrlPreviewSettings: function() { + if (!this.refs.url_preview_settings) { return q(); } + return this.refs.url_preview_settings.saveSettings(); + }, + saveEncryption: function () { if (!this.refs.encrypt) { return q(); }