-
Notifications
You must be signed in to change notification settings - Fork 382
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
Refactor username input lookup component #11451
Refactor username input lookup component #11451
Conversation
I wonder if having a |
@observer | ||
export default class CreateAnnouncement extends React.Component<Props> { | ||
private usernameInputInitialProps: typeof this.model.propsForUsernameInput = { | ||
// dummy value so the field isn't nullablel runInAction in contructor doesn't count as initialized. |
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.
"nullablel" 🤔 (the sentence also ends up unreadable)
additionally, this works:
this.stuff = runInAction(() => {
...
return valueForStuff;
});
this.xhr.userLookup.done((user) => runInAction(() => { | ||
if (user.id > 0) { | ||
this.props.userByName.set(currentCheckingUser, user); | ||
this.xhr.userLookup = apiLookup([currentCheckingUser]); |
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.
the function name is a bit too generic...
type: 'POST', | ||
url: route('users.check-username-exists'), | ||
}); | ||
this.xhr = apiLookup([username]); |
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.
the gift link generated in user menu should be @
prefixed as it was previously strictly username lookup
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.
or maybe just prefix it before sending the request
if (response.users.length > 0) { | ||
this.user = response.users[0]; | ||
} else { | ||
this.user = userNotFoundJson; |
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.
the response isn't an observable so might as well just response.users[0] ?? userNotFoundJson
?
@@ -26,11 +31,12 @@ public function index() | |||
if (ctype_digit($id)) { | |||
$numericIds[] = $id; | |||
} elseif (present($id)) { | |||
$stringIds[] = $id; | |||
$stringIds[] = $id[0] ? substr($id, 1) : $id; |
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.
I think you forgot a === '@'
there's also UsernamesForDbLookup::make
(but it also ignores _
/
difference)
} | ||
} | ||
|
||
private validUsersContains(userIdOrUsername?: string | null) { |
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.
...shouldn't this be Contain
instead? 🤔
To be used by #11377
Combined the
checkUsernameExists
into the new lookup as well.