-
Notifications
You must be signed in to change notification settings - Fork 15
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
[GAL-4417] Mobile mention #1992
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Bundle SizesCompared against 68b13ed Route: No significant changes found Dynamic import: No significant changes found |
…z/mobile-mention
); | ||
}; | ||
|
||
type CommentProps = { |
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.
lets rename the type too to match the component name if it's no longer just for comments
mentionsRef | ||
); | ||
|
||
const processedText = useMemo(() => { |
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.
would be awesome to have tests for this logic
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.
100%
); | ||
|
||
const processedText = useMemo(() => { | ||
const elements: CommentElement[] = []; |
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 decomposing this into different helper functions could help make this easier to read. it could also make debugging the issue from slack a bit easier
<WarningLinkBottomSheet redirectUrl={redirectUrl} ref={bottomSheetRef} /> | ||
<ProcessedText | ||
text={captionWithMarkdownLinks} | ||
mentionsRef={removeNullValues(feedPost.mentions)} |
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 removeNullValues
is worth memoizing
useEffect(() => { | ||
if (activeCommentId && ref.current) { | ||
const index = comments.findIndex((comment) => comment.dbid === activeCommentId); | ||
if (index !== -1) { | ||
setTimeout(() => { | ||
if (!ref.current) { | ||
return; | ||
} | ||
ref.current.scrollToIndex({ index, animated: true }); | ||
}, 200); | ||
} | ||
} | ||
}, [activeCommentId, comments]); |
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 freaking sweet
mentionsRef | ||
); | ||
|
||
const processedText = useMemo(() => { |
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.
100%
|
||
const navigation = useNavigation<MainTabStackNavigatorProp>(); | ||
|
||
const noficationData: NotificationDataType = useMemo(() => { |
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.
small typo :)
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.
Fixed it!
} | ||
|
||
// Calculate the length difference between the old alias and the new mention | ||
const lengthDifference = mention.label.length + 2 - aliasKeyword.length; // +1 for the @ |
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.
+1 or +2 in your comment?
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.
Updated the comment!
It should be + 2
[mentions, message, setMessage, aliasKeyword, selection.start] | ||
); | ||
|
||
const handleSetMessage = useCallback( |
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.
imo i think the logic in handleSetMention
and handleSetMessage
should be unit tested
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.
Agree! Will write the unit test for this hooks
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.
thanks for addressing comments!! this is looking great
@@ -0,0 +1,123 @@ | |||
import { graphql, readInlineData } from 'react-relay'; |
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.
Nice I like this file 🧠
Summary of Changes
ProcessedText
component to supportplain link
,markdown link
andmentions
Demo or Before/After Pics
Full flow mentions
CleanShot.2023-10-10.at.12.15.49.mp4
Notification metioned from comment
CleanShot.2023-10-10.at.12.21.38.mp4
Notification mentioned from post
CleanShot.2023-10-10.at.12.22.08.mp4
ProcessedText on comment
CleanShot.2023-10-10.at.12.22.41.mp4
ProcessedText on post
CleanShot.2023-10-10.at.12.23.43.mp4
Edge Cases
Testing Steps
Checklist
Please make sure to review and check all of the following: