diff --git a/src/components/views/dialogs/RoomUpgradeDialog.js b/src/components/views/dialogs/RoomUpgradeDialog.js index 403fbf4f77..ce8b93f693 100644 --- a/src/components/views/dialogs/RoomUpgradeDialog.js +++ b/src/components/views/dialogs/RoomUpgradeDialog.js @@ -47,7 +47,9 @@ export default React.createClass({ _onUpgradeClick: function() { this.setState({busy: true}); - MatrixClientPeg.get().upgradeRoom(this.props.room.roomId, this._targetVersion).catch((err) => { + MatrixClientPeg.get().upgradeRoom(this.props.room.roomId, this._targetVersion).then(() => { + this.props.onFinished(true); + }).catch((err) => { const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); Modal.createTrackedDialog('Failed to upgrade room', '', ErrorDialog, { title: _t("Failed to upgrade room"), @@ -82,10 +84,9 @@ export default React.createClass({ return (

diff --git a/src/components/views/rooms/RoomUpgradeWarningBar.js b/src/components/views/rooms/RoomUpgradeWarningBar.js index 589608dcfa..c2e2ba89d4 100644 --- a/src/components/views/rooms/RoomUpgradeWarningBar.js +++ b/src/components/views/rooms/RoomUpgradeWarningBar.js @@ -20,6 +20,7 @@ import sdk from '../../../index'; import Modal from '../../../Modal'; import { _t } from '../../../languageHandler'; +import MatrixClientPeg from "../../../MatrixClientPeg"; module.exports = React.createClass({ displayName: 'RoomUpgradeWarningBar', @@ -29,6 +30,24 @@ module.exports = React.createClass({ recommendation: PropTypes.object.isRequired, }, + componentWillMount: function() { + const tombstone = this.props.room.currentState.getStateEvents("m.room.tombstone", ""); + this.setState({upgraded: tombstone && tombstone.getContent().replacement_room}); + + MatrixClientPeg.get().on("RoomState.events", this._onStateEvents); + }, + + _onStateEvents: function(event, state) { + if (!this.props.room || event.getRoomId() !== this.props.room.roomId) { + return; + } + + if (event.getType() !== "m.room.tombstone") return; + + const tombstone = this.props.room.currentState.getStateEvents("m.room.tombstone", ""); + this.setState({upgraded: tombstone && tombstone.getContent().replacement_room}); + }, + onUpgradeClick: function() { const RoomUpgradeDialog = sdk.getComponent('dialogs.RoomUpgradeDialog'); Modal.createTrackedDialog('Upgrade Room Version', '', RoomUpgradeDialog, {room: this.props.room}); @@ -37,19 +56,8 @@ module.exports = React.createClass({ render: function() { const AccessibleButton = sdk.getComponent('elements.AccessibleButton'); - return ( -

-
- {_t( - "This room is running room version , which this homeserver has " + - "marked as unstable.", - {}, - { - "roomVersion": () => {this.props.room.getVersion()}, - "i": (sub) => {sub}, - }, - )} -
+ let doUpgradeWarnings = ( +

{_t( @@ -74,6 +82,33 @@ module.exports = React.createClass({ {_t("Upgrade this room to the recommended room version")}

+
+ ); + + if (this.state.upgraded) { + doUpgradeWarnings = ( +
+

+ {_t("This room has already been upgraded.")} +

+
+ ); + } + + return ( +
+
+ {_t( + "This room is running room version , which this homeserver has " + + "marked as unstable.", + {}, + { + "roomVersion": () => {this.props.room.getVersion()}, + "i": (sub) => {sub}, + }, + )} +
+ {doUpgradeWarnings}
{_t("Only room administrators will see this warning")}
diff --git a/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js b/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js index cabc196e40..20c270fe29 100644 --- a/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js +++ b/src/components/views/settings/tabs/room/AdvancedRoomSettingsTab.js @@ -38,8 +38,13 @@ export default class AdvancedRoomSettingsTab extends React.Component { componentWillMount() { // we handle lack of this object gracefully later, so don't worry about it failing here. - MatrixClientPeg.get().getRoom(this.props.roomId).getRecommendedVersion().then((v) => { - this.setState({upgradeRecommendation: v}); + const room = MatrixClientPeg.get().getRoom(this.props.roomId); + room.getRecommendedVersion().then((v) => { + const tombstone = room.currentState.getStateEvents("m.room.tombstone", ""); + this.setState({ + upgraded: tombstone && tombstone.getContent().replacement_room, + upgradeRecommendation: v, + }); }); } @@ -65,7 +70,7 @@ export default class AdvancedRoomSettingsTab extends React.Component { } let roomUpgradeButton; - if (this.state.upgradeRecommendation && this.state.upgradeRecommendation.needsUpgrade) { + if (this.state.upgradeRecommendation && this.state.upgradeRecommendation.needsUpgrade && !this.state.upgraded) { roomUpgradeButton = (

diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index e4dbaa593c..1291d5b86a 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -812,8 +812,9 @@ "Not now": "Not now", "Don't ask me again": "Don't ask me again", "Add a topic": "Add a topic", - "This room is running room version , which this homeserver has marked as unstable.": "This room is running room version , which this homeserver has marked as unstable.", "Upgrading this room will shut down the current instance of the room and create an upgraded room with the same name.": "Upgrading this room will shut down the current instance of the room and create an upgraded room with the same name.", + "This room has already been upgraded.": "This room has already been upgraded.", + "This room is running room version , which this homeserver has marked as unstable.": "This room is running room version , which this homeserver has marked as unstable.", "Only room administrators will see this warning": "Only room administrators will see this warning", "This Room": "This Room", "All Rooms": "All Rooms",