-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable auto suggestion for transfer input based off of users own transfer history #1964
Enable auto suggestion for transfer input based off of users own transfer history #1964
Conversation
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 looks great overall. I'd rather avoid adding the uniq
dependency and instead building the list of usernames like this:
currentAccount.get('transfer_history').reduce((acc, cur) => ({...acc, cur: true}), {})
and then just Object.keys()
it.
this way we don't add more library weight.
I agree. I will make the suggested change. |
Ok I was able to remove the need for Wasn't able to get reduce to work the way I wanted. Maybe you can modify the filter to use reduce if you prefer. However this does result in the expected result of a sanitized array. |
One use case I can think of where this would cause a problem is if a user had already transferred to a bad/wrong account, it would keep showing up in their list going forward. Could it at least check the list against the blacklisted accounts? Hopefully that will cover the worst scenarios. |
what if we weighted a user's followed accounts to the top of the autocomplete list & denoted them as such? |
That would be good to do too. |
Great suggestions. Thanks for actually taking this one into consideration. I have been getting an immense benefit from the alpha version. |
alright i've got this nice & cleaned up; switched to a more accessible autocomplete component, autocomplete includes followed users as well as previous transfers along with the # of times you transferred to them todo:
|
to be clear, i think the only two immediate & critical issues are truncating the list & style feedback; the other two things can happen in later PRs |
const transferToLog = currentAccount.get('transfer_history').reduce((acc, cur) => { | ||
if (cur.getIn([1, 'op', 0]) === 'transfer') { | ||
const username = cur.getIn([1, 'op', 1, 'to']); | ||
const numTransfers = acc.get(username) ? acc.get(username).numTransfers + 1 : 1 |
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.
semi pls
i've rebased this PR; i'm happy with where it's at. @relativityboy take a peek. |
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.
.toMap() | ||
.map(username => ({ username, label: labelFollowingUser })) | ||
.merge(transferToLog) | ||
.sortBy(u => u.numTransfers) |
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.
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.
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.
ah found a condition where it doesn't work, fixing it now...
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.
It didn't sort at all on live data. .sortBy
return(s/ed) a list that has the same order as this.props.following
.
There were 2 transfers in the list generated by .merge(transferToLog)
with the rest being undefined. Neither of those had their order changed. The comparator fn will prob need to move to an a > b? 1 : (a < b? : -1 : 0)
operation.
.merge(transferToLog) | ||
.sortBy(u => u.numTransfers) | ||
.reverse() | ||
.toArray(); |
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.
We need to add a limit to 10 users (as suggested by @bnchdrff )
ok, made some changes: limited to 20 followed users & 20 transfer history users, and refactored to a method that only runs once (no need for a wrapper quite yet, we can do that if this has to be reused somewhere else) |
i'm not sure how to do the negative rep thing quickly/easily ... i'd rather put that part into another PR since it's another boatload of work. the getComputedStyle error is tricky; it's in |
the these were both defined in things seem to run fine if i remove them, and there are no refs to this variable in our sourcetree; @valzav @roadscape @relativityboy any idea what the purpose of |
No idea |
just checked if |
|
Grepping |
I've updated the sortBy call to order by |
@relativityboy looks fine to me; you aren't using that const yet though! |
if you want to use a const for that one truncation, also pls use it for the other one as well |
Implementation looks good to me, this will be a useful feature. Reliance on transfers list is fine for now, we can leverage better APIs in the future to populate the autocomplete. Before merging we need clarification from @valzav why |
@roadscape, I think you are right - TYPED_ARRAY_SUPPORT was needed for the buffer lib, it must be James who added it (I most probably just helped him with webpack's config). Not sure if it's steel needed. I would suggest to try to remove and check if it breaks anything. |
Thanks Val, James' commits around that one have to do with adding a QR reader which has since been disabled. I also found a reference to this flag being related to browser compatibility issues with typed arrays (iOS/Safari in that case). Browser support for typed arrays looks better currently: https://caniuse.com/#feat=typedarrays In condenser, buffer seems to be mainly involved in these operations:
|
i'm testing those ops now, and also looking through the code for other |
tested login, image upload, posting, and account creation -- no errors found! |
remove unused global override see discussion at #1964 (comment)
Issue
Due to the inability to turn on basic autocomplete in the transfer form, users were encountering issues and scams by sending transfers to users with the wrong name. This is largely due to the fact that users had to constantly retype the name of the users they were sending transfers to.
Solution
As a solution to this issue, I have enabled the ability for condenser to check the users transfer history and suggest accounts based off this information.
Additional Config Options
This implementation of the autosuggest transfer feature activates only when the first letter of the name is typed and matched with available results. On top of this, the results are limited to 10 matches at a time in an effort to reduce screen disruption.
Screenshots