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

Avatars Stage 1 #378

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Avatars Stage 1 #378

wants to merge 9 commits into from

Conversation

zbarnz
Copy link
Member

@zbarnz zbarnz commented Dec 1, 2022

Description

Notion Ticket: https://www.notion.so/thomashudsonnotes/User-icons-bc9aee65f1d24687896a9633cb377b5a

Stage 1 of avatars. This pull request includes user avatars that have a bright easily visible background with username initials.

Next stage will include upload functionality and database google link storage without the frontend

Screenshots of feature

Screenshot 2022-11-30 231440
Screenshot 2022-11-30 231548
Screenshot 2022-11-30 231659

Type of change

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

How Has This Been Tested?

Created new accounts, signed in and out of account and into other ones.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

api/lib/index.js Outdated
@@ -14,7 +14,7 @@ const start = async () => {

// body parser is deprecated so in Express 4.16+ ( we have 4.17.1) we use
// these two lines for body parsing
app.use(express.json());
app.use(express.json()); //max size mongodb data
Copy link
Member

@thudsonbu thudsonbu Dec 1, 2022

Choose a reason for hiding this comment

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

I think this is probably just a leftover.

@thudsonbu
Copy link
Member

What do you think about adding the avatar on the user object? My reasoning is that we probably won't need to lookup the avatar separately from the user and with the avatar on the user object queries will be very efficient.

Comment on lines 23 to 28
const initials = subject_username
.match(/(\b\S)?/g)
.join("")
.match(/(^\S|\S$)?/g)
.join("")
.toUpperCase();
Copy link
Member

Choose a reason for hiding this comment

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

Since the initials are calculated based on the user.username we shouldn't store them. Otherwise there is the potential for the avatar to deviate from the user object. Instead, we can just perform this operation on the frontend in an avatar component.

Copy link
Member Author

Choose a reason for hiding this comment

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

How would they deviate? Well have to run the operation for every avatar object there could be 100

Copy link
Member

Choose a reason for hiding this comment

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

The deviation could happen when a user's username changes after the avatar has been created. It is a little inconvenient that we will have to perform that operation for all of a groups users but even in that worst case I don't think it would take more then a millisecond. Generally you only want to denormalize like that when the operation is highly expensive because data deviations are dangerous.

Copy link
Member

Choose a reason for hiding this comment

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

Also, we will probably need to calculate it for non-users anyway so I don't think we can really avoid it by doing it 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.

Okay, do we want users to change usernames though?

Copy link
Member

Choose a reason for hiding this comment

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

I don't see why we would want to block changing them.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see why we would want to block changing them.

@@ -0,0 +1,52 @@
import { Modal, Avatar } from "@mui/material";
Copy link
Member

@thudsonbu thudsonbu Dec 1, 2022

Choose a reason for hiding this comment

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

I think that it could be a good idea to create a separate account page at user/[_id] (with largely the same format as this modal). That should make it easier for us to allow group members to look at other user's accounts.

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 tried this initially there was just so much white space I couldn't make it look good. If you think well have enough content to give it its own page we could certainly do it.

Copy link
Member

Choose a reason for hiding this comment

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

With the groups and integrations related things on the page we should have enough content.

@thudsonbu thudsonbu assigned zbarnz and unassigned thudsonbu Dec 1, 2022
@thudsonbu
Copy link
Member

@zbarnz Is this ready for review?

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.

3 participants