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

Don't show addresses that have already been picked #1678

Closed
wants to merge 11 commits into from

Conversation

t3chguy
Copy link
Member

@t3chguy t3chguy commented Dec 29, 2017

Fixes element-hq/element-web#5792 and probably others
Apologies for tiny other little nit fixes in the same commit

Signed-off-by: Michael Telatynski 7t3chguy@gmail.com


Edit:
now also excludes addresses which are already in the group/room

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
@t3chguy
Copy link
Member Author

t3chguy commented Dec 29, 2017

now that there's a generic thing for excluding addresses, should I remove the includeSelf prop, which doesn't appear to ever actually be used (no instance of this dialog ever has includeSelf:true)

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
@t3chguy t3chguy force-pushed the t3chguy/dedup_address_picker branch from 5b8ca7a to a7f317a Compare December 29, 2017 23:35
@lukebarnard1
Copy link
Contributor

now that there's a generic thing for excluding addresses, should I remove the includeSelf prop, which doesn't appear to ever actually be used (no instance of this dialog ever has includeSelf:true)

Sure, go for it!

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Copy link
Contributor

@lukebarnard1 lukebarnard1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One tiny change but otherwise, this looks really good :)

I continue to be concerned about the AddressPicker API, which mandates use of strings "mx-room-id" and "mx-user-id". But refactoring that could be done another time I think.

@@ -63,10 +63,21 @@ export function showStartChatInviteDialog() {
}

export function showRoomInviteDialog(roomId) {
const cli = MatrixClientPeg.get();
const room = cli.getRoom(roomId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably put the above two lines onto one line - cli is otherwise unused.

isKnown: true,
});
// Don't add it if it is in the excludedAddresses
if (this.props.excludedAddresses.find((entry) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is O(n^2) but optimising it would probably be premature.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one could be optimized by changing the format of exludedAddresses to be a map, for constant time access

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, but I'd suggest we wait until there's an actual perf problem (so for now we choose readability over speed)

@@ -511,6 +513,12 @@ module.exports = React.createClass({
const AddressSelector = sdk.getComponent("elements.AddressSelector");
this.scrollElement = null;

const queryList = this.state.queryList.filter((query) => {
return !this.state.userList.find((entry) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is O(n^2) but optimising it would also probably be premature.

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
@t3chguy
Copy link
Member Author

t3chguy commented Jan 5, 2018

I continue to be concerned about the AddressPicker API, which mandates use of strings "mx-room-id" and "mx-user-id". But refactoring that could be done another time I think.

what would you prefer/suggest?
enums/consts?

@lukebarnard1
Copy link
Contributor

Well for a thing that picks "addresses" it seems far to concerned about users and rooms. But I think last time I was worrying about this I concluded that we'd need a UserPicker and RoomPicker, both wrapping AddressPicker. But to be honest, I'm not convinced that this would actually make things easy to digest overall.

Copy link
Contributor

@lukebarnard1 lukebarnard1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a tiny amount of comment feedback - otherwise LGTM

excludedAddresses: groupStore.getGroupMembers().concat(groupStore.getGroupInvitedMembers()).map((member) => ({
addressType: 'mx-user-id',
address: member.userId,
})), // no need to add ourselves as we must already be in the group
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"ourselves" is a bit ambiguous, I'd advise that when commenting it's best to talk about "the user" or "the members of the group" etc.

}).map((member) => ({
addressType: 'mx-user-id',
address: member.userId,
})), // no need to add ourselves as we must already be in the room
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(see above)

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
@dbkr
Copy link
Member

dbkr commented Jan 5, 2018

I'm actually not 100% sure on excluding users/rooms who already in the room/group: it won't be very obvious why they aren't appearing if you don't realise they've already been invited (or are already in the room). @ara4n @lampholder wdyt?

@t3chguy
Copy link
Member Author

t3chguy commented Jan 5, 2018

@dbkr how about graying them out in the dropdown instead then, with hoverover tooltip?

@dbkr
Copy link
Member

dbkr commented Jan 8, 2018

Seems ok from my PoV, although @ara4n / @lampholder should probably weigh in.

@lampholder
Copy link
Member

Hey @t3chguy could you fix the merge conflict and then I'll run it on lant.uk and test the UX? Ta!

@t3chguy
Copy link
Member Author

t3chguy commented Jun 21, 2018

Splitting this PR out.
#2000 is the first half
second half to follow

@t3chguy t3chguy closed this Jun 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding rooms to a community should not suggest rooms I've queued for adding
4 participants