Sensible error for setting room colours if you're a guest
This commit is contained in:
parent
e311a963c1
commit
6dce555865
1 changed files with 14 additions and 1 deletions
|
@ -16,8 +16,10 @@ limitations under the License.
|
||||||
var q = require("q");
|
var q = require("q");
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
|
|
||||||
|
var sdk = require('../../../index');
|
||||||
var Tinter = require('../../../Tinter');
|
var Tinter = require('../../../Tinter');
|
||||||
var MatrixClientPeg = require("../../../MatrixClientPeg");
|
var MatrixClientPeg = require("../../../MatrixClientPeg");
|
||||||
|
var Modal = require("../../../Modal");
|
||||||
|
|
||||||
var ROOM_COLORS = [
|
var ROOM_COLORS = [
|
||||||
// magic room default values courtesy of Ribot
|
// magic room default values courtesy of Ribot
|
||||||
|
@ -74,12 +76,23 @@ module.exports = React.createClass({
|
||||||
if (originalState.primary_color !== this.state.primary_color ||
|
if (originalState.primary_color !== this.state.primary_color ||
|
||||||
originalState.secondary_color !== this.state.secondary_color) {
|
originalState.secondary_color !== this.state.secondary_color) {
|
||||||
console.log("ColorSettings: Saving new color");
|
console.log("ColorSettings: Saving new color");
|
||||||
|
// We would like guests to be able to set room colour but currently
|
||||||
|
// they can't, so we still send the request but display a sensible
|
||||||
|
// error if it fails.
|
||||||
return MatrixClientPeg.get().setRoomAccountData(
|
return MatrixClientPeg.get().setRoomAccountData(
|
||||||
this.props.room.roomId, "org.matrix.room.color_scheme", {
|
this.props.room.roomId, "org.matrix.room.color_scheme", {
|
||||||
primary_color: this.state.primary_color,
|
primary_color: this.state.primary_color,
|
||||||
secondary_color: this.state.secondary_color
|
secondary_color: this.state.secondary_color
|
||||||
}
|
}
|
||||||
);
|
).catch(function(err) {
|
||||||
|
if (err.errcode == 'M_GUEST_ACCESS_FORBIDDEN') {
|
||||||
|
var NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog");
|
||||||
|
Modal.createDialog(NeedToRegisterDialog, {
|
||||||
|
title: "Please Register",
|
||||||
|
description: "Guest users can't create new rooms. Please register to create room and start a chat."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return q(); // no color diff
|
return q(); // no color diff
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue