diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js
index b8be3e017a..0f34e02161 100644
--- a/src/components/structures/MatrixChat.js
+++ b/src/components/structures/MatrixChat.js
@@ -1054,6 +1054,7 @@ export default React.createClass({
modal.close();
if (this.state.currentRoomId === roomId) {
dis.dispatch({action: 'view_next_room'});
+ dis.dispatch({action: 'close_room_settings'});
}
}, (err) => {
modal.close();
diff --git a/src/components/views/dialogs/RoomSettingsDialog.js b/src/components/views/dialogs/RoomSettingsDialog.js
index 7336373e32..94625a028d 100644
--- a/src/components/views/dialogs/RoomSettingsDialog.js
+++ b/src/components/views/dialogs/RoomSettingsDialog.js
@@ -44,6 +44,19 @@ export default class RoomSettingsDialog extends React.Component {
onFinished: PropTypes.func.isRequired,
};
+ componentWillMount(): void {
+ this.dispatcherRef = dis.register(this._onAction);
+ }
+
+ componentWillUnmount(): void {
+ dis.unregister(this.dispatcherRef);
+ }
+
+ _onAction = (payload) => {
+ if (payload.action !== 'close_room_settings') return;
+ this.props.onFinished();
+ };
+
_getTabs() {
const tabs = [];
diff --git a/src/components/views/room_settings/UrlPreviewSettings.js b/src/components/views/room_settings/UrlPreviewSettings.js
index fe2a2bacf4..1662692164 100644
--- a/src/components/views/room_settings/UrlPreviewSettings.js
+++ b/src/components/views/room_settings/UrlPreviewSettings.js
@@ -1,7 +1,7 @@
/*
Copyright 2016 OpenMarket Ltd
Copyright 2017 Travis Ralston
-Copyright 2018 New Vector Ltd
+Copyright 2018-2019 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -16,12 +16,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-import {MatrixClient} from "matrix-js-sdk";
const React = require('react');
import PropTypes from 'prop-types';
const sdk = require("../../../index");
import { _t, _td } from '../../../languageHandler';
import SettingsStore, {SettingLevel} from "../../../settings/SettingsStore";
+import dis from "../../../dispatcher";
+import MatrixClientPeg from "../../../MatrixClientPeg";
module.exports = React.createClass({
@@ -31,21 +32,16 @@ module.exports = React.createClass({
room: PropTypes.object,
},
- contextTypes: {
- matrixClient: PropTypes.instanceOf(MatrixClient).isRequired,
- },
-
- saveSettings: function() {
- const promises = [];
- if (this.refs.urlPreviewsRoom) promises.push(this.refs.urlPreviewsRoom.save());
- if (this.refs.urlPreviewsSelf) promises.push(this.refs.urlPreviewsSelf.save());
- return promises;
+ _onClickUserSettings: (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ dis.dispatch({action: 'view_user_settings'});
},
render: function() {
const SettingsFlag = sdk.getComponent("elements.SettingsFlag");
const roomId = this.props.room.roomId;
- const isEncrypted = this.context.matrixClient.isRoomEncrypted(roomId);
+ const isEncrypted = MatrixClientPeg.get().isRoomEncrypted(roomId);
let previewsForAccount = null;
let previewsForRoom = null;
@@ -56,13 +52,13 @@ module.exports = React.createClass({
if (accountEnabled) {
previewsForAccount = (
_t("You have enabled URL previews by default.", {}, {
- 'a': (sub)=>{ sub },
+ 'a': (sub)=>{ sub },
})
);
} else if (accountEnabled) {
previewsForAccount = (
_t("You have disabled URL previews by default.", {}, {
- 'a': (sub)=>{ sub },
+ 'a': (sub)=>{ sub },
})
);
}
@@ -73,9 +69,7 @@ module.exports = React.createClass({