-
-
Notifications
You must be signed in to change notification settings - Fork 829
Don't show addresses that have already been picked #1678
Conversation
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>
now that there's a generic thing for excluding addresses, should I remove the |
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
5b8ca7a
to
a7f317a
Compare
Sure, go for it! |
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
There was a problem hiding this 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.
src/RoomInvite.js
Outdated
@@ -63,10 +63,21 @@ export function showStartChatInviteDialog() { | |||
} | |||
|
|||
export function showRoomInviteDialog(roomId) { | |||
const cli = MatrixClientPeg.get(); | |||
const room = cli.getRoom(roomId); |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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>
what would you prefer/suggest? |
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. |
There was a problem hiding this 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
src/GroupAddressPicker.js
Outdated
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 |
There was a problem hiding this comment.
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.
src/RoomInvite.js
Outdated
}).map((member) => ({ | ||
addressType: 'mx-user-id', | ||
address: member.userId, | ||
})), // no need to add ourselves as we must already be in the room |
There was a problem hiding this comment.
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>
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? |
@dbkr how about graying them out in the dropdown instead then, with hoverover tooltip? |
Seems ok from my PoV, although @ara4n / @lampholder should probably weigh in. |
Hey @t3chguy could you fix the merge conflict and then I'll run it on lant.uk and test the UX? Ta! |
Splitting this PR out. |
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