Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Wmwragg/chat multi invite #469

Merged
merged 29 commits into from
Sep 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
28dcbb2
Refactored the queryList into seperate AddressSelector component
wmwragg Sep 12, 2016
7d58968
Correctly positioning the selected element if list shrinks in size
wmwragg Sep 12, 2016
d538377
Added an inviteList state to hold all the users to invite, but curren…
wmwragg Sep 12, 2016
5acdb82
The dismiss function now correctly deletes the dismissed element. Als…
wmwragg Sep 12, 2016
4836025
First pass at adding multiple addresses, can only add from AddressSel…
wmwragg Sep 12, 2016
e28a3f1
Don't allow someone who is already on the invite list to appear in th…
wmwragg Sep 12, 2016
5b2cc55
Refactored AddressTile to use string address rather than user object,…
wmwragg Sep 12, 2016
44b8c29
Allow addresses to be added as text when space or comma are pressed
wmwragg Sep 12, 2016
95d9df7
Make an invalid mx user an unknown user AddressTile
wmwragg Sep 12, 2016
5a0a72e
Added styling for unknown addresses
wmwragg Sep 12, 2016
96299e8
Need cto push the actual userId not the toLowerCase version, as userI…
wmwragg Sep 12, 2016
0f720dd
Oops, toLowerCase call in wrong place
wmwragg Sep 12, 2016
a7ea193
A supplied roomId property, will make the dialog use that room for th…
wmwragg Sep 13, 2016
99dfcb4
It's no longer a onde to one chat dialog, as you can invite multiple …
wmwragg Sep 13, 2016
ca2ba55
Added error checking, and UI
wmwragg Sep 13, 2016
0b26776
Small refactor to handle Direct Message chat as well as multi invite …
wmwragg Sep 13, 2016
cba76d6
Moved the isValidAddress method to the Invite utilty object
wmwragg Sep 13, 2016
524eeaa
Merge up from develop
wmwragg Sep 13, 2016
538b68a
Updated with the new createRoom DM stuff
wmwragg Sep 13, 2016
ca1bb0f
Added new Invite button in the RHS footer which calls the new 'view_i…
wmwragg Sep 13, 2016
2db8f4a
Added pass through of roomId
wmwragg Sep 13, 2016
2fd9e2a
Pull out multi-inviting from MultiInviteDialog
dbkr Sep 13, 2016
e95a622
Merge remote-tracking branch 'origin/wmwragg/chat-multi-invite' into …
dbkr Sep 13, 2016
a53e009
Missed a brace
dbkr Sep 13, 2016
4067715
Correct path for MultiInviter
dbkr Sep 13, 2016
f7f907a
Merge pull request #467 from matrix-org/dbkr/wmwragg/chat-multi-invite
wmwragg Sep 13, 2016
272dd82
Added multi invite functionality
wmwragg Sep 13, 2016
890100a
Silly mistake fixed, spotted by Dave (cheers)
wmwragg Sep 13, 2016
7fa1029
Added valid but unknown mx user
wmwragg Sep 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/Invite.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
*/

import MatrixClientPeg from './MatrixClientPeg';
import MultiInviter from './utils/MultiInviter';

const emailRegex = /^\S+@\S+\.\S+$/;

Expand Down Expand Up @@ -43,3 +44,40 @@ export function inviteToRoom(roomId, addr) {
throw new Error('Unsupported address');
}
}

/**
* Invites multiple addresses to a room
* Simpler interface to utils/MultiInviter but with
* no option to cancel.
*
* @param {roomId} The ID of the room to invite to
* @param {array} Array of strings of addresses to invite. May be matrix IDs or 3pids.
* @returns Promise
*/
export function inviteMultipleToRoom(roomId, addrs) {
this.inviter = new MultiInviter(roomId);
return this.inviter.invite(addrs);
}

/**
* Checks is the supplied address is valid
*
* @param {addr} The mx userId or email address to check
* @returns true, false, or null for unsure
*/
export function isValidAddress(addr) {
// Check if the addr is a valid type
var addrType = this.getAddressType(addr);
if (addrType === "mx") {
let user = MatrixClientPeg.get().getUser(addr);
if (user) {
return true;
} else {
return null;
}
} else if (addrType === "email") {
return true;
} else {
return false;
}
}
1 change: 1 addition & 0 deletions src/component-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module.exports.components['views.dialogs.NeedToRegisterDialog'] = require('./com
module.exports.components['views.dialogs.QuestionDialog'] = require('./components/views/dialogs/QuestionDialog');
module.exports.components['views.dialogs.SetDisplayNameDialog'] = require('./components/views/dialogs/SetDisplayNameDialog');
module.exports.components['views.dialogs.TextInputDialog'] = require('./components/views/dialogs/TextInputDialog');
module.exports.components['views.elements.AddressSelector'] = require('./components/views/elements/AddressSelector');
module.exports.components['views.elements.AddressTile'] = require('./components/views/elements/AddressTile');
module.exports.components['views.elements.EditableText'] = require('./components/views/elements/EditableText');
module.exports.components['views.elements.EditableTextContainer'] = require('./components/views/elements/EditableTextContainer');
Expand Down
15 changes: 14 additions & 1 deletion src/components/structures/MatrixChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ module.exports = React.createClass({
case 'view_create_chat':
this._createChat();
break;
case 'view_invite':
this._invite(payload.roomId);
break;
case 'notifier_enabled':
this.forceUpdate();
break;
Expand Down Expand Up @@ -512,7 +515,17 @@ module.exports = React.createClass({
_createChat: function() {
var ChatInviteDialog = sdk.getComponent("dialogs.ChatInviteDialog");
Modal.createDialog(ChatInviteDialog, {
title: "Start a one to one chat",
title: "Start a new chat",
});
},

_invite: function(roomId) {
var ChatInviteDialog = sdk.getComponent("dialogs.ChatInviteDialog");
Modal.createDialog(ChatInviteDialog, {
title: "Invite new room members",
button: "Send Invites",
description: "Who would you like to add to this room?",
roomId: roomId,
});
},

Expand Down
Loading