Skip to content
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

Merged
merged 39 commits into from
Oct 13, 2023
Merged

[GAL-4417] Mobile mention #1992

merged 39 commits into from
Oct 13, 2023

Conversation

jakzaizzat
Copy link
Collaborator

@jakzaizzat jakzaizzat commented Oct 5, 2023

Summary of Changes

  • User able to mention another user in comment and Post
  • Update the ProcessedText component to support plain link, markdown link and mentions
  • Added notification if someone mentioned you

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

  1. Mention multiple user and community in one shot
  2. Mention someone and remove it
  3. Combine all format - mention, plain link and markdown link
  4. Mention notification in comment but the comment is at the end of bottom sheet (the ui should auto scroll down)

Testing Steps

  1. You can mention in post composer and comment

Checklist

Please make sure to review and check all of the following:

  • I've tested the changes and all tests pass.
  • (if mobile) I've tested the changes on both light and dark modes.

@vercel
Copy link

vercel bot commented Oct 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gallery ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 13, 2023 9:52am

@github-actions
Copy link

github-actions bot commented Oct 5, 2023

Bundle Sizes

Compared against 68b13ed

Route: No significant changes found

Dynamic import: No significant changes found

@jakzaizzat jakzaizzat changed the title Jakz/mobile mention [GAL-4417] Mobile mention Oct 10, 2023
);
};

type CommentProps = {
Copy link
Collaborator

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(() => {
Copy link
Collaborator

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

Copy link
Contributor

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[] = [];
Copy link
Collaborator

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)}
Copy link
Collaborator

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

Comment on lines +31 to +43
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]);
Copy link
Contributor

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(() => {
Copy link
Contributor

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(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small typo :)

Copy link
Collaborator Author

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 @
Copy link
Contributor

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?

Copy link
Collaborator Author

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(
Copy link
Contributor

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

Copy link
Collaborator Author

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

Copy link
Collaborator

@kaitoo1 kaitoo1 left a 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';
Copy link
Collaborator

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 🧠

@jakzaizzat jakzaizzat merged commit c825945 into main Oct 13, 2023
6 checks passed
@jakzaizzat jakzaizzat deleted the jakz/mobile-mention branch October 13, 2023 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants