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(discussions): add avatars #3587

Merged
merged 5 commits into from
Jun 3, 2024
Merged

Conversation

benfurber
Copy link
Member

@benfurber benfurber commented May 24, 2024

PR Checklist

PR Type

  • New feature (non-breaking change which adds functionality)

Description

Add option user profile image to comments (and tidies up various responsive layout stuff).

Screenshots/Videos

Screenshot 2024-05-24 at 16 10 34

@davehakkens
Copy link
Contributor

Niceeee! Could we display this functionality only to beta-testers first? Since it might bring some weird UI changes

@davehakkens davehakkens added the Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview label May 24, 2024
Copy link
Contributor

github-actions bot commented May 24, 2024

Visit the preview URL for this PR (updated for commit c97ad47):

https://onearmy-next--pr3587-feat-discussion-add-7gevp0ga.web.app

(expires Wed, 03 Jul 2024 14:42:01 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 6d65e4f8fee2f6ab2da0c1c3b85b8797d66afa59

@davehakkens davehakkens marked this pull request as ready for review May 24, 2024 21:01
@davehakkens davehakkens requested a review from a team as a code owner May 24, 2024 21:01
@benfurber
Copy link
Member Author

@davehakkens, et al. I'm not finished on this branch so doesn't need a review yet.

@benfurber benfurber marked this pull request as draft May 27, 2024 08:41
@davehakkens
Copy link
Contributor

well i'm looking anyway 🤓

@benfurber
Copy link
Member Author

Niceeee! Could we display this functionality only to beta-testers first? Since it might bring some weird UI changes

Sorry @davehakkens, I missed this comment yesterday. I think based on the current beta tester wrapper component and approach, a fair amount of extra re-coding would be needed to enable them to evaulate this change on prod.

Maybe instead the preview link/branch could be left open for longer to get tested by a broader group before merging?

@benfurber benfurber force-pushed the feat/discussion/add-avatars branch from da3c114 to 8923f53 Compare May 28, 2024 14:27
@davehakkens
Copy link
Contributor

It's not a matter of adding an auth wrapper to only display the avatar to beta-testers? (It should be easy to add this)
I would prefer to test features like this as beta-tester:

  • Avoid things being released that are buggy (feels like we had a little to much of that recently)
  • This is the first time visually avatars are shown. But on the profile settings this isnt very well intergrated yet (workspaces use landscape images and others can be weirdly cropped) could forsee a bunch scenarios coming that could be fixed upfront in beta-test.
  • Test with live data, the dev-site isnt a good representation
  • A broader group of users will see/test it then devs. Which gives more eyes and feedback from other devices and browsers.

@benfurber benfurber force-pushed the feat/discussion/add-avatars branch from 8923f53 to 3c197aa Compare May 28, 2024 14:52
@benfurber
Copy link
Member Author

@davehakkens I take all your points.

It's more work, because:

  1. We add the beta tester wrapper at the app code level while the avatar addition code is nested five(ish) components deep in the component library.
  2. The beta tester wrapper layout stylings is a little clunky for small elements.
  3. The wrapper currently adds a 4px border on each side. So that's 8 per axis. As currently coded the avatar is only 30x30 for the mobile display. So if I put the wrapper litterally right around the image, it would changes the experience of feature.

So I'll:

  1. Add a property from the DiscussionContainer on down to the CommentItem to set whether to show the avatar or not.
  2. Add the beta tester wrapper at the DiscussionContainer level so that the wrapper border doesn't get in the way of experiencing the feature.

@davehakkens
Copy link
Contributor

Ah i see. Thanks for explaining @benfurber
Your plan sounds good to me!

@benfurber benfurber force-pushed the feat/discussion/add-avatars branch 3 times, most recently from 012c834 to 26d21ab Compare May 29, 2024 10:30
Copy link

codecov bot commented May 29, 2024

Codecov Report

Attention: Patch coverage is 87.43719% with 25 lines in your changes are missing coverage. Please review.

Project coverage is 68.40%. Comparing base (2f9cc11) to head (c97ad47).
Report is 27 commits behind head on master.

Files Patch % Lines
...ackages/components/src/CommentItem/CommentItem.tsx 87.06% 15 Missing ⚠️
...components/src/CommentItem/CommentItem.stories.tsx 69.23% 4 Missing ⚠️
...iscussionContainer/DiscussionContainer.stories.tsx 40.00% 3 Missing ⚠️
src/stores/Discussions/discussions.store.tsx 77.77% 2 Missing ⚠️
...ctions/src/userUpdates/updateDiscussionComments.ts 95.23% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #3587    +/-   ##
========================================
  Coverage   68.40%   68.40%            
========================================
  Files         445      449     +4     
  Lines       13849    14010   +161     
  Branches     2479     2499    +20     
========================================
+ Hits         9473     9584   +111     
- Misses       4333     4383    +50     
  Partials       43       43            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

cypress bot commented May 29, 2024

2 flaky tests on run #5725 ↗︎

0 77 1 0 Flakiness 2

Details:

refactor: rename function for convention
Project: onearmy-community-platform Commit: c97ad4738c
Status: Passed Duration: 04:56 💡
Started: Jun 3, 2024 12:35 PM Ended: Jun 3, 2024 12:40 PM
Flakiness  research/write.spec.ts • 1 flaky test • ci-chrome

View Output Video

Test Artifacts
[Research] > [Create research article] > [By Authenticated] Test Replay Screenshots Video
Flakiness  howto/read.spec.ts • 1 flaky test • ci-chrome

View Output Video

Test Artifacts
... > [See all info] Test Replay Screenshots Video

Review all test suite changes for PR #3587 ↗︎

@benfurber benfurber force-pushed the feat/discussion/add-avatars branch from 93b11ad to bc4abcc Compare May 29, 2024 13:42
@benfurber
Copy link
Member Author

benfurber commented May 29, 2024

On Mobile

Before

IMG_1342

Now

For reg users

IMG_1341

BT: When no images present

IMG_1344

BT: With images

IMG_2792BCDF88DF-1

@benfurber benfurber marked this pull request as ready for review May 29, 2024 14:33
@pizzaisdavid
Copy link
Collaborator

pizzaisdavid commented May 30, 2024

General remark about what I am seeing in the codebase and this pull request: it seems that it is a common case that something changes about a user, for example image (or location) and then their contributions need to be updated (via handleUserUpdates, I think.)

My first thought is that it would be less of a headache to only store the id of a user and the content of their comment. And then, when we want to show the avatar (or location) the id is used to lookup the user and then get their current avatar, merging the two together (either on the backend when requesting discussion data or on the frontend.)

All this logic about if the image changed could go away. So it would just be that the user can change their avatar as much as they want and only the data in the user collection would change, discussions would not get updated at all.

Maybe there is some Firebase limitation/justification or some other good reason. 😄

@mariojsnunes
Copy link
Contributor

Maybe there is some Firebase limitation/justification or some other good reason. 😄

Yes its a common practice for a NoSql database.
If we eventually migrate to supabase which uses postgres, we would implement the approach you described

@pizzaisdavid
Copy link
Collaborator

pizzaisdavid commented May 31, 2024

I worked at a company that used Mongodb (which is NoSQL) and they were doing the method I suggested. But on some further research, it is kinda like they were treating NoSQL like SQL (strict validation on fields via Mongoose, using stuff like foreign keys, no duplicate data spread across the database.)

But I have found this video series, which uses a very similar example to the usecase here (user submissions and wanting to show profile pictures.) https://youtu.be/v_hR4K4auoQ?list=PLl-K7zZEsYLluG5MCVEzXAQ7ACZBCuZgZ&t=380 (timstamped for convenience) I guess it is a general trend of NoSQL and the approach optimizes reads over edits, which makes sense. As the edits don't happen often. And something something about Firebase billing.

Consider my comment resolved. Thanks for the push to learn more @mariojsnunes 😄

@benfurber
Copy link
Member Author

benfurber commented May 31, 2024

Thanks @mariojsnunes and @pizzaisdavid. Any more code level comments?

@benfurber benfurber merged commit e296c10 into master Jun 3, 2024
21 checks passed
@benfurber benfurber deleted the feat/discussion/add-avatars branch June 3, 2024 12:50
@onearmy-bot
Copy link
Collaborator

🎉 This PR is included in version 1.188.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend released Review allow-preview ✅ Has received manual check for malicious code and can be safely built for preview
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants