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

feat: show edited message label in message UI #2514

Merged
merged 6 commits into from
May 15, 2024
Merged

Conversation

khushal87
Copy link
Member

@khushal87 khushal87 commented May 14, 2024

🎯 Goal

The feature adds a new edited message label that can also be expanded with the click of a message.

PFA the video to see how it looks and works.

Screen.Recording.2024-05-14.at.3.44.21.PM.mov

I have made our date formatter function reusable and better in the PR as well. This removes code duplicacy from the SDK and is readable as well.

🛠 Implementation details

🎨 UI Changes

iOS
Before After
Android
Before After

🧪 Testing

☑️ Checklist

  • I have signed the Stream CLA (required)
  • PR targets the develop branch
  • Documentation is updated
  • New code is tested in main example apps, including all possible scenarios
    • SampleApp iOS and Android
    • Expo iOS and Android

@@ -78,7 +78,7 @@
"path": "0.12.7",
"react-native-markdown-package": "1.8.2",
"react-native-url-polyfill": "^1.3.0",
"stream-chat": "8.17.0"
"stream-chat": "8.21.0"
Copy link
Member

Choose a reason for hiding this comment

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

Any reason why you aren't using the latest LLC?

Copy link
Member Author

Choose a reason for hiding this comment

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

No reasons. We haven't tested it yet, and that is why didn't upgrade to the latest.

Copy link
Member

Choose a reason for hiding this comment

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

I think when updating a dependency, we should always update to the latest version. We test it anyways, this way we can cover a wider version range.

Copy link
Member

Choose a reason for hiding this comment

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

we usually update to the latest.. @khushal87 could you upgrade and quickly check.. nothing should break with a patch release update

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to the latest version. I don't see any problem as such as of now.

Comment on lines 59 to 62
const MemoizedMessageEditedTimestamp = React.memo(
MessageEditedTimestampWithContext,
areEqual,
) as typeof MessageEditedTimestampWithContext;
Copy link
Member

Choose a reason for hiding this comment

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

Are there any good reasons why we are memorizing this component? All I can see are troubles with stale data down the road.

Copy link
Member Author

Choose a reason for hiding this comment

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

There are no reasons. This has been a pattern in our RN SDK for a long time, and it's just been followed here as well. This way, we don't pass props down the hierarchy but can utilize them from context(if present). These are things that have to be improved everywhere explicitly.

Copy link
Member

Choose a reason for hiding this comment

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

I think excessive memoization creates more problems than benefits. I understand this is a legacy pattern we also have in our React SDK but we should slowly move away from it (at least for the new stuff). Otherwise, we keep increasing the technical dept and we are breaking the expectations of React components - re-render when a prop changes.

Copy link
Member

Choose a reason for hiding this comment

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

Also I see a problem with this memoisation, what if the timestamp changes?

we can remove this memoisation all together, there seems to be nothing expensive in the render function that warrants for memoisation here

Copy link
Member Author

Choose a reason for hiding this comment

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

I have removed it completely

Comment on lines 59 to 62
const MemoizedMessageTimestamp = React.memo(
MessageTimestampWithContext,
() => true,
) as typeof MessageTimestampWithContext;
Copy link
Member

Choose a reason for hiding this comment

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

Also here, this component will never receive an update. Do we need the memorization on this level?
I'm not sure how expensive getDateString() is. At best, I'd useMemo it only.

Copy link
Member Author

Choose a reason for hiding this comment

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

#2514 (comment)

Done for the same reasons so that tDateTimeParser can be taken both as a prop or a context if the prop is unavailable here. 🙂

Copy link
Member

Choose a reason for hiding this comment

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

I'm referring to () => true. This component will show the stale timestamp until it remounts. Updates are cheap, we shouldn't be memoizing aggressively on a component level.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have removed the memoization here completely.

@khushal87 khushal87 merged commit e19be3c into develop May 15, 2024
5 of 6 checks passed
@khushal87 khushal87 deleted the edited-message-label branch May 15, 2024 15:38
@github-actions github-actions bot mentioned this pull request May 15, 2024
6 tasks
@stream-ci-bot
Copy link
Contributor

🎉 This PR is included in version 5.30.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants