chore(friends): tighten Direct-Add gate consistency
Per code-review: directAddDisplay now reads directAt === -1
instead of re-deriving includes('@'); add a one-line comment on
showDirectAdd so the predicate's intent is obvious at first read.
This commit is contained in:
@@ -464,13 +464,14 @@ function AddFriendTab({
|
|||||||
|
|
||||||
const trimmedQuery = query.trim();
|
const trimmedQuery = query.trim();
|
||||||
const directAt = trimmedQuery.lastIndexOf('@');
|
const directAt = trimmedQuery.lastIndexOf('@');
|
||||||
|
// Allow bare handle (no @) or @ at non-edge position; hide @, @bob, bob@.
|
||||||
const showDirectAdd = trimmedQuery.length > 0
|
const showDirectAdd = trimmedQuery.length > 0
|
||||||
&& (directAt === -1 || (directAt > 0 && directAt < trimmedQuery.length - 1));
|
&& (directAt === -1 || (directAt > 0 && directAt < trimmedQuery.length - 1));
|
||||||
// Bare handle gets the home host appended for display only — submission
|
// Bare handle gets the home host appended for display only — submission
|
||||||
// still uses the raw trimmed query.
|
// still uses the raw trimmed query.
|
||||||
const directAddDisplay = trimmedQuery.includes('@')
|
const directAddDisplay = directAt === -1
|
||||||
? trimmedQuery
|
? `${trimmedQuery}@${window.location.host}`
|
||||||
: `${trimmedQuery}@${window.location.host}`;
|
: trimmedQuery;
|
||||||
|
|
||||||
// Direct Add handler
|
// Direct Add handler
|
||||||
const handleDirectAdd = async () => {
|
const handleDirectAdd = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user