add support for groups
This commit is contained in:
parent
b797efa06d
commit
568ebebd34
1 changed files with 22 additions and 5 deletions
|
@ -26,6 +26,7 @@ var linkable_clients = [
|
|||
room_id_url(id) { return "https://riot.im/app/#/room/" + id },
|
||||
user_url(userId) { return "https://riot.im/app/#/user/" + userId },
|
||||
msg_url(msg) { return "https://riot.im/app/#/room/" + msg },
|
||||
group_url(group) { return "https://riot.im/app/#/group/" + group },
|
||||
maturity: "Stable",
|
||||
comments: "Fully-featured Matrix client for Web, iOS & Android",
|
||||
},
|
||||
|
@ -143,10 +144,10 @@ export default React.createClass({
|
|||
return;
|
||||
}
|
||||
|
||||
if (!this.isAliasValid(entity) && !this.isUserIdValid(entity) && !this.isMsglinkValid(entity) && !this.isRoomIdValid(entity)) {
|
||||
if (!this.isAliasValid(entity) && !this.isUserIdValid(entity) && !this.isMsglinkValid(entity) && !this.isRoomIdValid(entity) && !this.isGroupValid(entity)) {
|
||||
this.setState({
|
||||
entity: entity,
|
||||
error: "Invalid room alias, user ID or message permalink '" + entity + "'",
|
||||
error: "Invalid room alias, user ID, message permalink or group '" + entity + "'",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -175,8 +176,8 @@ export default React.createClass({
|
|||
ev.preventDefault();
|
||||
|
||||
var entity = this.refs.prompt.value.trim();
|
||||
if (!this.isAliasValid(entity) && !this.isUserIdValid(entity)) {
|
||||
this.setState({ error: "Invalid room alias or user ID" });
|
||||
if (!this.isAliasValid(entity) && !this.isUserIdValid(entity) && !this.isGroupValid(entity)) {
|
||||
this.setState({ error: "Invalid room alias, user ID or group" });
|
||||
return;
|
||||
}
|
||||
var loc = window.location;
|
||||
|
@ -212,6 +213,12 @@ export default React.createClass({
|
|||
return (msglink.match(/^[\!#]([^\/:]+?):(.+?)\/\$([^\/:]+?):(.+?)$/) && encodeURI(msglink) === msglink);
|
||||
},
|
||||
|
||||
isGroupValid(group) {
|
||||
console.log(group);
|
||||
console.log(encodeURI(group));
|
||||
return (group.match(/^\+([^\/:]+?):(.+)$/) && encodeURI(group) === group);
|
||||
},
|
||||
|
||||
render() {
|
||||
var error;
|
||||
if (this.state.error) {
|
||||
|
@ -226,6 +233,7 @@ export default React.createClass({
|
|||
var isRoomId = this.isRoomIdValid(this.state.entity);
|
||||
var isUser = this.isUserIdValid(this.state.entity);
|
||||
var isMsg = this.isMsglinkValid(this.state.entity);
|
||||
var isGroup = this.isGroupValid(this.state.entity);
|
||||
|
||||
var links;
|
||||
|
||||
|
@ -248,6 +256,9 @@ export default React.createClass({
|
|||
else if (isMsg) {
|
||||
description = <span><b>this message</b></span>;
|
||||
}
|
||||
else if (isGroup) {
|
||||
description = <span>the <b>{ this.state.entity }</b> group</span>;
|
||||
}
|
||||
|
||||
links = (
|
||||
<div key="links" className="mxt_HomePage_links">
|
||||
|
@ -294,6 +305,9 @@ export default React.createClass({
|
|||
else if (isMsg && client.msg_url) {
|
||||
link = client.msg_url(this.state.entity);
|
||||
}
|
||||
else if (isGroup && client.group_url) {
|
||||
link = client.group_url(this.state.entity);
|
||||
}
|
||||
if (!link) return null;
|
||||
|
||||
return (
|
||||
|
@ -333,6 +347,9 @@ export default React.createClass({
|
|||
else if (isMsg && client.msg_instructions) {
|
||||
instructions = client.msg_instructions(this.state.entity);
|
||||
}
|
||||
else if (isGroup && client.group_instructions) {
|
||||
instructions = client.group_instructions(this.state.entity);
|
||||
}
|
||||
if (!instructions) return null;
|
||||
|
||||
return (
|
||||
|
@ -381,7 +398,7 @@ export default React.createClass({
|
|||
prompt = [
|
||||
<div key="inputBox" className="mxt_HomePage_inputBox">
|
||||
<form onSubmit={ this.onSubmit }>
|
||||
<input autoFocus className="mxt_HomePage_inputBox_prompt" value={ this.state.entity } ref="prompt" size="36" type="text" placeholder="#room:domain.com or @user:domain.com" />
|
||||
<input autoFocus className="mxt_HomePage_inputBox_prompt" value={ this.state.entity } ref="prompt" size="36" type="text" placeholder="#room:domain.com, @user:domain.com or +group:domain.com" />
|
||||
<input className="mxt_HomePage_inputBox_button" type="submit" value="Get link!" />
|
||||
</form>
|
||||
{ error }
|
||||
|
|
Loading…
Reference in a new issue