Merge remote-tracking branch 'origin/develop' into dbkr/update_on_room_name
This commit is contained in:
commit
a3746ea1b6
6 changed files with 87 additions and 6 deletions
|
@ -412,6 +412,7 @@ export function stopMatrixClient() {
|
||||||
if (cli) {
|
if (cli) {
|
||||||
cli.stopClient();
|
cli.stopClient();
|
||||||
cli.removeAllListeners();
|
cli.removeAllListeners();
|
||||||
|
cli.store.deleteAllData();
|
||||||
MatrixClientPeg.unset();
|
MatrixClientPeg.unset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
import q from "q";
|
||||||
import Matrix from 'matrix-js-sdk';
|
import Matrix from 'matrix-js-sdk';
|
||||||
import utils from 'matrix-js-sdk/lib/utils';
|
import utils from 'matrix-js-sdk/lib/utils';
|
||||||
import EventTimeline from 'matrix-js-sdk/lib/models/event-timeline';
|
import EventTimeline from 'matrix-js-sdk/lib/models/event-timeline';
|
||||||
|
@ -71,7 +72,16 @@ class MatrixClientPeg {
|
||||||
const opts = utils.deepCopy(this.opts);
|
const opts = utils.deepCopy(this.opts);
|
||||||
// the react sdk doesn't work without this, so don't allow
|
// the react sdk doesn't work without this, so don't allow
|
||||||
opts.pendingEventOrdering = "detached";
|
opts.pendingEventOrdering = "detached";
|
||||||
this.get().startClient(opts);
|
|
||||||
|
let promise = this.matrixClient.store.startup();
|
||||||
|
// log any errors when starting up the database (if one exists)
|
||||||
|
promise.catch((err) => { console.error(err); });
|
||||||
|
|
||||||
|
// regardless of errors, start the client. If we did error out, we'll
|
||||||
|
// just end up doing a full initial /sync.
|
||||||
|
promise.finally(() => {
|
||||||
|
this.get().startClient(opts);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getCredentials(): MatrixClientCreds {
|
getCredentials(): MatrixClientCreds {
|
||||||
|
@ -111,6 +121,14 @@ class MatrixClientPeg {
|
||||||
if (localStorage) {
|
if (localStorage) {
|
||||||
opts.sessionStore = new Matrix.WebStorageSessionStore(localStorage);
|
opts.sessionStore = new Matrix.WebStorageSessionStore(localStorage);
|
||||||
}
|
}
|
||||||
|
if (window.indexedDB && localStorage) {
|
||||||
|
opts.store = new Matrix.IndexedDBStore(
|
||||||
|
new Matrix.IndexedDBStoreBackend(window.indexedDB),
|
||||||
|
new Matrix.SyncAccumulator(), {
|
||||||
|
localStorage: localStorage,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
this.matrixClient = Matrix.createClient(opts);
|
this.matrixClient = Matrix.createClient(opts);
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,7 @@ export default React.createClass({
|
||||||
collapsedRhs={this.props.collapse_rhs}
|
collapsedRhs={this.props.collapse_rhs}
|
||||||
enableLabs={this.props.config.enableLabs}
|
enableLabs={this.props.config.enableLabs}
|
||||||
referralBaseUrl={this.props.config.referralBaseUrl}
|
referralBaseUrl={this.props.config.referralBaseUrl}
|
||||||
|
teamToken={this.props.teamToken}
|
||||||
/>;
|
/>;
|
||||||
if (!this.props.collapse_rhs) right_panel = <RightPanel opacity={this.props.sideOpacity}/>;
|
if (!this.props.collapse_rhs) right_panel = <RightPanel opacity={this.props.sideOpacity}/>;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -464,6 +464,10 @@ module.exports = React.createClass({
|
||||||
this.notifyNewScreen('directory');
|
this.notifyNewScreen('directory');
|
||||||
break;
|
break;
|
||||||
case 'view_home_page':
|
case 'view_home_page':
|
||||||
|
if (!this._teamToken) {
|
||||||
|
dis.dispatch({action: 'view_room_directory'});
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._setPage(PageTypes.HomePage);
|
this._setPage(PageTypes.HomePage);
|
||||||
this.notifyNewScreen('home');
|
this.notifyNewScreen('home');
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -109,6 +109,10 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
// true if RightPanel is collapsed
|
// true if RightPanel is collapsed
|
||||||
collapsedRhs: React.PropTypes.bool,
|
collapsedRhs: React.PropTypes.bool,
|
||||||
|
|
||||||
|
// Team token for the referral link. If falsy, the referral section will
|
||||||
|
// not appear
|
||||||
|
teamToken: React.PropTypes.string,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -462,7 +466,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderReferral: function() {
|
_renderReferral: function() {
|
||||||
const teamToken = window.localStorage.getItem('mx_team_token');
|
const teamToken = this.props.teamToken;
|
||||||
if (!teamToken) {
|
if (!teamToken) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
|
Copyright 2017 Vector Creations Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -35,6 +36,47 @@ function parseIntWithDefault(val, def) {
|
||||||
return isNaN(res) ? def : res;
|
return isNaN(res) ? def : res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const BannedUser = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
member: React.PropTypes.object.isRequired, // js-sdk RoomMember
|
||||||
|
},
|
||||||
|
|
||||||
|
_onUnbanClick: function() {
|
||||||
|
const ConfirmUserActionDialog = sdk.getComponent("dialogs.ConfirmUserActionDialog");
|
||||||
|
Modal.createDialog(ConfirmUserActionDialog, {
|
||||||
|
member: this.props.member,
|
||||||
|
action: 'Unban',
|
||||||
|
danger: false,
|
||||||
|
onFinished: (proceed) => {
|
||||||
|
if (!proceed) return;
|
||||||
|
|
||||||
|
MatrixClientPeg.get().unban(
|
||||||
|
this.props.member.roomId, this.props.member.userId,
|
||||||
|
).catch((err) => {
|
||||||
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
|
Modal.createDialog(ErrorDialog, {
|
||||||
|
title: "Failed to unban",
|
||||||
|
description: err.message,
|
||||||
|
});
|
||||||
|
}).done();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
<AccessibleButton className="mx_RoomSettings_unbanButton"
|
||||||
|
onClick={this._onUnbanClick}
|
||||||
|
>
|
||||||
|
Unban
|
||||||
|
</AccessibleButton>
|
||||||
|
{this.props.member.userId}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'RoomSettings',
|
displayName: 'RoomSettings',
|
||||||
|
|
||||||
|
@ -74,6 +116,9 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
ScalarMessaging.startListening();
|
ScalarMessaging.startListening();
|
||||||
|
|
||||||
|
MatrixClientPeg.get().on("RoomMember.membership", this._onRoomMemberMembership);
|
||||||
|
|
||||||
MatrixClientPeg.get().getRoomDirectoryVisibility(
|
MatrixClientPeg.get().getRoomDirectoryVisibility(
|
||||||
this.props.room.roomId
|
this.props.room.roomId
|
||||||
).done((result) => {
|
).done((result) => {
|
||||||
|
@ -102,6 +147,11 @@ module.exports = React.createClass({
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
ScalarMessaging.stopListening();
|
ScalarMessaging.stopListening();
|
||||||
|
|
||||||
|
const cli = MatrixClientPeg.get();
|
||||||
|
if (cli) {
|
||||||
|
cli.removeListener("RoomMember.membership", this._onRoomMemberMembership);
|
||||||
|
}
|
||||||
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'ui_opacity',
|
action: 'ui_opacity',
|
||||||
sideOpacity: 1.0,
|
sideOpacity: 1.0,
|
||||||
|
@ -501,6 +551,11 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_onRoomMemberMembership: function() {
|
||||||
|
// Update, since our banned user list may have changed
|
||||||
|
this.forceUpdate();
|
||||||
|
},
|
||||||
|
|
||||||
_renderEncryptionSection: function() {
|
_renderEncryptionSection: function() {
|
||||||
var cli = MatrixClientPeg.get();
|
var cli = MatrixClientPeg.get();
|
||||||
var roomState = this.props.room.currentState;
|
var roomState = this.props.room.currentState;
|
||||||
|
@ -611,11 +666,9 @@ module.exports = React.createClass({
|
||||||
<div>
|
<div>
|
||||||
<h3>Banned users</h3>
|
<h3>Banned users</h3>
|
||||||
<ul className="mx_RoomSettings_banned">
|
<ul className="mx_RoomSettings_banned">
|
||||||
{banned.map(function(member, i) {
|
{banned.map(function(member) {
|
||||||
return (
|
return (
|
||||||
<li key={i}>
|
<BannedUser key={member.userId} member={member} />
|
||||||
{member.userId}
|
|
||||||
</li>
|
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in a new issue