Merge remote-tracking branch 'origin/develop' into read_receipts
This commit is contained in:
commit
2f783a7ba9
13 changed files with 67 additions and 76 deletions
|
@ -27,7 +27,8 @@
|
||||||
"matrix-js-sdk": "https://github.com/matrix-org/matrix-js-sdk.git#develop",
|
"matrix-js-sdk": "https://github.com/matrix-org/matrix-js-sdk.git#develop",
|
||||||
"optimist": "^0.6.1",
|
"optimist": "^0.6.1",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"react": "^0.13.3",
|
"react": "^0.14.2",
|
||||||
|
"react-dom": "^0.14.2",
|
||||||
"react-loader": "^1.4.0"
|
"react-loader": "^1.4.0"
|
||||||
},
|
},
|
||||||
"//deps": "The loader packages are here because webpack in a project that depends on us needs them in this package's node_modules folder",
|
"//deps": "The loader packages are here because webpack in a project that depends on us needs them in this package's node_modules folder",
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2015 OpenMarket Ltd
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var url = require ('url');
|
|
||||||
|
|
||||||
function getServiceUrl() {
|
|
||||||
var parsedUrl = url.parse(window.location.href);
|
|
||||||
return parsedUrl.protocol + "//" + parsedUrl.host + parsedUrl.pathname;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
getServiceUrl: getServiceUrl
|
|
||||||
};
|
|
|
@ -18,6 +18,7 @@ limitations under the License.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var React = require('react');
|
var React = require('react');
|
||||||
|
var ReactDOM = require('react-dom');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
DialogContainerId: "mx_Dialog_Container",
|
DialogContainerId: "mx_Dialog_Container",
|
||||||
|
@ -52,7 +53,7 @@ module.exports = {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
React.render(dialog, this.getOrCreateContainer());
|
ReactDOM.render(dialog, this.getOrCreateContainer());
|
||||||
|
|
||||||
return {close: closeDialog};
|
return {close: closeDialog};
|
||||||
},
|
},
|
||||||
|
@ -77,7 +78,7 @@ module.exports = {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
React.render(dialog, this.getOrCreateContainer());
|
ReactDOM.render(dialog, this.getOrCreateContainer());
|
||||||
|
|
||||||
return {close: closeDialog};
|
return {close: closeDialog};
|
||||||
},
|
},
|
||||||
|
|
|
@ -24,7 +24,7 @@ linkifyMatrix(linkify);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
linkifyElement(this.refs.content.getDOMNode(), linkifyMatrix.options);
|
linkifyElement(this.refs.content, linkifyMatrix.options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,6 @@ linkifyMatrix(linkify);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
linkifyElement(this.refs.content.getDOMNode(), linkifyMatrix.options);
|
linkifyElement(this.refs.content, linkifyMatrix.options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@ linkifyMatrix(linkify);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
linkifyElement(this.refs.content.getDOMNode(), linkifyMatrix.options);
|
linkifyElement(this.refs.content, linkifyMatrix.options);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ module.exports = {
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this.dispatcherRef = dis.register(this.onAction);
|
this.dispatcherRef = dis.register(this.onAction);
|
||||||
this.sentHistory.init(
|
this.sentHistory.init(
|
||||||
this.refs.textarea.getDOMNode(),
|
this.refs.textarea,
|
||||||
this.props.room.roomId
|
this.props.room.roomId
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -143,14 +143,14 @@ module.exports = {
|
||||||
onAction: function(payload) {
|
onAction: function(payload) {
|
||||||
switch (payload.action) {
|
switch (payload.action) {
|
||||||
case 'focus_composer':
|
case 'focus_composer':
|
||||||
this.refs.textarea.getDOMNode().focus();
|
this.refs.textarea.focus();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyDown: function (ev) {
|
onKeyDown: function (ev) {
|
||||||
if (ev.keyCode === KeyCode.ENTER) {
|
if (ev.keyCode === KeyCode.ENTER) {
|
||||||
var input = this.refs.textarea.getDOMNode().value;
|
var input = this.refs.textarea.value;
|
||||||
if (input.length === 0) {
|
if (input.length === 0) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return;
|
return;
|
||||||
|
@ -179,7 +179,7 @@ module.exports = {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (self.refs.textarea && self.refs.textarea.getDOMNode().value != '') {
|
if (self.refs.textarea && self.refs.textarea.value != '') {
|
||||||
self.onTypingActivity();
|
self.onTypingActivity();
|
||||||
} else {
|
} else {
|
||||||
self.onFinishedTyping();
|
self.onFinishedTyping();
|
||||||
|
@ -188,13 +188,13 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onEnter: function(ev) {
|
onEnter: function(ev) {
|
||||||
var contentText = this.refs.textarea.getDOMNode().value;
|
var contentText = this.refs.textarea.value;
|
||||||
|
|
||||||
var cmd = SlashCommands.processInput(this.props.room.roomId, contentText);
|
var cmd = SlashCommands.processInput(this.props.room.roomId, contentText);
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
if (!cmd.error) {
|
if (!cmd.error) {
|
||||||
this.refs.textarea.getDOMNode().value = '';
|
this.refs.textarea.value = '';
|
||||||
}
|
}
|
||||||
if (cmd.promise) {
|
if (cmd.promise) {
|
||||||
cmd.promise.done(function() {
|
cmd.promise.done(function() {
|
||||||
|
@ -241,12 +241,12 @@ module.exports = {
|
||||||
action: 'message_send_failed'
|
action: 'message_send_failed'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.refs.textarea.getDOMNode().value = '';
|
this.refs.textarea.value = '';
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
},
|
},
|
||||||
|
|
||||||
onTab: function(ev, sortedMembers) {
|
onTab: function(ev, sortedMembers) {
|
||||||
var textArea = this.refs.textarea.getDOMNode();
|
var textArea = this.refs.textarea;
|
||||||
if (!this.tabStruct.completing) {
|
if (!this.tabStruct.completing) {
|
||||||
this.tabStruct.completing = true;
|
this.tabStruct.completing = true;
|
||||||
this.tabStruct.index = 0;
|
this.tabStruct.index = 0;
|
||||||
|
|
|
@ -17,20 +17,17 @@ limitations under the License.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var MatrixClientPeg = require("../../MatrixClientPeg");
|
var MatrixClientPeg = require("../../MatrixClientPeg");
|
||||||
var Cas = require("../../CasLogic");
|
var url = require("url");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
onCasClicked: function(ev) {
|
onCasClicked: function(ev) {
|
||||||
var serviceRedirectUrl = Cas.getServiceUrl() + "#/login/cas";
|
var cli = MatrixClientPeg.get();
|
||||||
var self = this;
|
var parsedUrl = url.parse(window.location.href, true);
|
||||||
MatrixClientPeg.get().getCasServer().done(function(data) {
|
parsedUrl.query["homeserver"] = cli.getHomeserverUrl();
|
||||||
var serverUrl = data.serverUrl + "/login?service=" + encodeURIComponent(serviceRedirectUrl);
|
parsedUrl.query["identityServer"] = cli.getIdentityServerUrl();
|
||||||
window.location.href = serverUrl;
|
var casUrl = MatrixClientPeg.get().getCasLoginUrl(url.format(parsedUrl));
|
||||||
}, function(error) {
|
window.location.href = casUrl;
|
||||||
self.setStep("stage_m.login.cas");
|
|
||||||
self.setState({errorText: 'Login failed.'});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -72,7 +72,7 @@ module.exports = {
|
||||||
{
|
{
|
||||||
type: "m.room.join_rules",
|
type: "m.room.join_rules",
|
||||||
content: {
|
content: {
|
||||||
"join_rules": this.state.is_private ? "invite" : "public"
|
"join_rule": this.state.is_private ? "invite" : "public"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ module.exports = {
|
||||||
deferred = deferred.then(function(res) {
|
deferred = deferred.then(function(res) {
|
||||||
response = res;
|
response = res;
|
||||||
return encryption.enableEncryption(
|
return encryption.enableEncryption(
|
||||||
cli, response.roomId, options.invite
|
cli, response.room_id, options.invite
|
||||||
);
|
);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return q(response) }
|
return q(response) }
|
||||||
|
|
|
@ -115,9 +115,11 @@ module.exports = {
|
||||||
onInvite: function(inputText) {
|
onInvite: function(inputText) {
|
||||||
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
|
||||||
var self = this;
|
var self = this;
|
||||||
// sanity check the input
|
|
||||||
inputText = inputText.trim(); // react requires es5-shim so we know trim() exists
|
inputText = inputText.trim(); // react requires es5-shim so we know trim() exists
|
||||||
if (inputText[0] !== '@' || inputText.indexOf(":") === -1) {
|
var isEmailAddress = /^\S+@\S+\.\S+$/.test(inputText);
|
||||||
|
|
||||||
|
// sanity check the input for user IDs
|
||||||
|
if (!isEmailAddress && (inputText[0] !== '@' || inputText.indexOf(":") === -1)) {
|
||||||
console.error("Bad user ID to invite: %s", inputText);
|
console.error("Bad user ID to invite: %s", inputText);
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Invite Error",
|
title: "Invite Error",
|
||||||
|
@ -125,12 +127,22 @@ module.exports = {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var promise;
|
||||||
|
if (isEmailAddress) {
|
||||||
|
promise = MatrixClientPeg.get().inviteByEmail(this.props.roomId, inputText);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
promise = MatrixClientPeg.get().invite(this.props.roomId, inputText);
|
||||||
|
}
|
||||||
|
|
||||||
self.setState({
|
self.setState({
|
||||||
inviting: true
|
inviting: true
|
||||||
});
|
});
|
||||||
console.log("Invite %s to %s", inputText, this.props.roomId);
|
console.log(
|
||||||
MatrixClientPeg.get().invite(this.props.roomId, inputText).done(
|
"Invite %s to %s - isEmail=%s", inputText, this.props.roomId, isEmailAddress
|
||||||
function(res) {
|
);
|
||||||
|
promise.done(function(res) {
|
||||||
console.log("Invited");
|
console.log("Invited");
|
||||||
self.setState({
|
self.setState({
|
||||||
inviting: false
|
inviting: false
|
||||||
|
|
|
@ -50,7 +50,7 @@ module.exports = {
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
if (this.refs.messageWrapper) {
|
if (this.refs.messageWrapper) {
|
||||||
var messageWrapper = this.refs.messageWrapper.getDOMNode();
|
var messageWrapper = this.refs.messageWrapper;
|
||||||
messageWrapper.removeEventListener('drop', this.onDrop);
|
messageWrapper.removeEventListener('drop', this.onDrop);
|
||||||
messageWrapper.removeEventListener('dragover', this.onDragOver);
|
messageWrapper.removeEventListener('dragover', this.onDragOver);
|
||||||
messageWrapper.removeEventListener('dragleave', this.onDragLeaveOrEnd);
|
messageWrapper.removeEventListener('dragleave', this.onDragLeaveOrEnd);
|
||||||
|
@ -85,7 +85,7 @@ module.exports = {
|
||||||
// scroll to bottom
|
// scroll to bottom
|
||||||
var messageWrapper = this.refs.messageWrapper;
|
var messageWrapper = this.refs.messageWrapper;
|
||||||
if (messageWrapper) {
|
if (messageWrapper) {
|
||||||
messageWrapper = messageWrapper.getDOMNode();
|
messageWrapper = messageWrapper;
|
||||||
messageWrapper.scrollTop = messageWrapper.scrollHeight;
|
messageWrapper.scrollTop = messageWrapper.scrollHeight;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -116,7 +116,7 @@ module.exports = {
|
||||||
if (room.roomId != this.props.roomId) return;
|
if (room.roomId != this.props.roomId) return;
|
||||||
|
|
||||||
if (this.refs.messageWrapper) {
|
if (this.refs.messageWrapper) {
|
||||||
var messageWrapper = this.refs.messageWrapper.getDOMNode();
|
var messageWrapper = this.refs.messageWrapper;
|
||||||
this.atBottom = (
|
this.atBottom = (
|
||||||
messageWrapper.scrollHeight - messageWrapper.scrollTop <=
|
messageWrapper.scrollHeight - messageWrapper.scrollTop <=
|
||||||
(messageWrapper.clientHeight + 150)
|
(messageWrapper.clientHeight + 150)
|
||||||
|
@ -166,7 +166,7 @@ module.exports = {
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
if (this.refs.messageWrapper) {
|
if (this.refs.messageWrapper) {
|
||||||
var messageWrapper = this.refs.messageWrapper.getDOMNode();
|
var messageWrapper = this.refs.messageWrapper;
|
||||||
|
|
||||||
messageWrapper.addEventListener('drop', this.onDrop);
|
messageWrapper.addEventListener('drop', this.onDrop);
|
||||||
messageWrapper.addEventListener('dragover', this.onDragOver);
|
messageWrapper.addEventListener('dragover', this.onDragOver);
|
||||||
|
@ -184,7 +184,7 @@ module.exports = {
|
||||||
componentDidUpdate: function() {
|
componentDidUpdate: function() {
|
||||||
if (!this.refs.messageWrapper) return;
|
if (!this.refs.messageWrapper) return;
|
||||||
|
|
||||||
var messageWrapper = this.refs.messageWrapper.getDOMNode();
|
var messageWrapper = this.refs.messageWrapper;
|
||||||
|
|
||||||
if (this.state.paginating && !this.waiting_for_paginate) {
|
if (this.state.paginating && !this.waiting_for_paginate) {
|
||||||
var heightGained = messageWrapper.scrollHeight - this.oldScrollHeight;
|
var heightGained = messageWrapper.scrollHeight - this.oldScrollHeight;
|
||||||
|
@ -203,7 +203,7 @@ module.exports = {
|
||||||
|
|
||||||
fillSpace: function() {
|
fillSpace: function() {
|
||||||
if (!this.refs.messageWrapper) return;
|
if (!this.refs.messageWrapper) return;
|
||||||
var messageWrapper = this.refs.messageWrapper.getDOMNode();
|
var messageWrapper = this.refs.messageWrapper;
|
||||||
if (messageWrapper.scrollTop < messageWrapper.clientHeight && this.state.room.oldState.paginationToken) {
|
if (messageWrapper.scrollTop < messageWrapper.clientHeight && this.state.room.oldState.paginationToken) {
|
||||||
this.setState({paginating: true});
|
this.setState({paginating: true});
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ module.exports = {
|
||||||
|
|
||||||
onMessageListScroll: function(ev) {
|
onMessageListScroll: function(ev) {
|
||||||
if (this.refs.messageWrapper) {
|
if (this.refs.messageWrapper) {
|
||||||
var messageWrapper = this.refs.messageWrapper.getDOMNode();
|
var messageWrapper = this.refs.messageWrapper;
|
||||||
var wasAtBottom = this.atBottom;
|
var wasAtBottom = this.atBottom;
|
||||||
this.atBottom = messageWrapper.scrollHeight - messageWrapper.scrollTop <= messageWrapper.clientHeight;
|
this.atBottom = messageWrapper.scrollHeight - messageWrapper.scrollTop <= messageWrapper.clientHeight;
|
||||||
if (this.atBottom && !wasAtBottom) {
|
if (this.atBottom && !wasAtBottom) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ var sdk = require('../../index');
|
||||||
var MatrixTools = require('../../MatrixTools');
|
var MatrixTools = require('../../MatrixTools');
|
||||||
var linkifyMatrix = require("../../linkify-matrix");
|
var linkifyMatrix = require("../../linkify-matrix");
|
||||||
|
|
||||||
var Cas = require("../../CasLogic");
|
var url = require('url');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
PageTypes: {
|
PageTypes: {
|
||||||
|
@ -142,14 +142,17 @@ module.exports = {
|
||||||
});
|
});
|
||||||
this.notifyNewScreen('login');
|
this.notifyNewScreen('login');
|
||||||
break;
|
break;
|
||||||
case 'cas_login':
|
case 'token_login':
|
||||||
if (this.state.logged_in) return;
|
if (this.state.logged_in) return;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var client = MatrixClientPeg.get();
|
MatrixClientPeg.replaceUsingUrls(
|
||||||
var serviceUrl = Cas.getServiceUrl();
|
payload.params.homeserver,
|
||||||
|
payload.params.identityServer
|
||||||
|
);
|
||||||
|
|
||||||
client.loginWithCas(payload.params.ticket, serviceUrl).done(function(data) {
|
var client = MatrixClientPeg.get();
|
||||||
|
client.loginWithToken(payload.params.loginToken).done(function(data) {
|
||||||
MatrixClientPeg.replaceUsingAccessToken(
|
MatrixClientPeg.replaceUsingAccessToken(
|
||||||
client.getHomeserverUrl(), client.getIdentityServerUrl(),
|
client.getHomeserverUrl(), client.getIdentityServerUrl(),
|
||||||
data.user_id, data.access_token
|
data.user_id, data.access_token
|
||||||
|
@ -158,8 +161,13 @@ module.exports = {
|
||||||
screen: undefined,
|
screen: undefined,
|
||||||
logged_in: true
|
logged_in: true
|
||||||
});
|
});
|
||||||
self.startMatrixClient();
|
|
||||||
self.notifyNewScreen('');
|
// We're left with the login token, hs and is url as query params
|
||||||
|
// in the url, a little nasty but let's redirect to clear them
|
||||||
|
var parsedUrl = url.parse(window.location.href);
|
||||||
|
parsedUrl.search = "";
|
||||||
|
window.location.href = url.format(parsedUrl);
|
||||||
|
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
self.notifyNewScreen('login');
|
self.notifyNewScreen('login');
|
||||||
self.setState({errorText: 'Login failed.'});
|
self.setState({errorText: 'Login failed.'});
|
||||||
|
@ -391,9 +399,9 @@ module.exports = {
|
||||||
action: 'start_login',
|
action: 'start_login',
|
||||||
params: params
|
params: params
|
||||||
});
|
});
|
||||||
} else if (screen == 'cas_login') {
|
} else if (screen == 'token_login') {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'cas_login',
|
action: 'token_login',
|
||||||
params: params
|
params: params
|
||||||
});
|
});
|
||||||
} else if (screen.indexOf('room/') == 0) {
|
} else if (screen.indexOf('room/') == 0) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ module.exports = {
|
||||||
var scriptTag = document.createElement('script');
|
var scriptTag = document.createElement('script');
|
||||||
window.mx_on_recaptcha_loaded = this.onCaptchaLoaded;
|
window.mx_on_recaptcha_loaded = this.onCaptchaLoaded;
|
||||||
scriptTag.setAttribute('src', global.location.protocol+"//www.google.com/recaptcha/api.js?onload=mx_on_recaptcha_loaded&render=explicit");
|
scriptTag.setAttribute('src', global.location.protocol+"//www.google.com/recaptcha/api.js?onload=mx_on_recaptcha_loaded&render=explicit");
|
||||||
this.refs.recaptchaContainer.getDOMNode().appendChild(scriptTag);
|
this.refs.recaptchaContainer.appendChild(scriptTag);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue