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

Add support for message avatars #41

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Half-Shot
Copy link
Contributor

Fixes #32

I'm not overly happy with the styling on this one because it feels like the avatars are a bit to one side, however I grew impatient with CSS and moved onto other things.

Timeline

image

Highlighted

image

@@ -36,8 +37,10 @@ class Message extends React.Component {
}
try {
const profile = await this.context.client.getProfile(this.props.event.sender);
const avatarUrl = profile.avatar_url && this.context.client.thumbnailLink(profile.avatar_url, 'scale', 48, 48);
Copy link
Member

Choose a reason for hiding this comment

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

Bleh, this actually will be bad if we call /profile for every message rendered. Sure we cache, but on first render the cache will be empty so we'll spam the server for the same profile. We should probably add an in-flight cache on Client.getProfile so we return the same HTTP promise for the same user, so we can at least guarantee only 1 HTTP hit per user (currently it's 1:1 based on the number of messages).

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

Successfully merging this pull request may close these issues.

use avatar & username on posts
2 participants