Skip to content

Commit

Permalink
Merge pull request #113 from weaponsforge/fix/viky-112
Browse files Browse the repository at this point in the history
put real profile_picture on /contacts with initial as fallback
  • Loading branch information
weaponsforge authored Apr 25, 2023
2 parents 44b6ac7 + 8e4c47f commit c0fd832
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
17 changes: 13 additions & 4 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"next": "13.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"use-sync-v": "^2.0.10"
"use-sync-v": "^2.0.16"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { downloadBlobFromStorage } from '@/lib/utils/firebase/storageutils'
import { Avatar, Paper, Typography, useTheme } from '@mui/material'
import { useRouter } from 'next/router'
import { updateSyncV } from 'use-sync-v'
import { updateSyncV, useQueryV } from 'use-sync-v'

const getInitial = (first, second, last) => {
const firstInitial = (first.match(
Expand Down Expand Up @@ -28,6 +29,12 @@ export const ContactCard = ({ contact }) => {
const router = useRouter()
const theme = useTheme()

const { data } = useQueryV(`public_picture.${JSON.stringify(contact.profile_picture_url)}`, async () => {
const response = await downloadBlobFromStorage(contact.profile_picture_url)
const public_picture_url = URL.createObjectURL(response)
return public_picture_url
})

const initial = getInitial(
contact.first_name,
contact.middle_name,
Expand Down Expand Up @@ -68,6 +75,7 @@ export const ContactCard = ({ contact }) => {
backgroundColor: `hsla(${backgroundColor},50%,80%,50%)`,
border: '1px solid grey',
}}
src={data}
>
{initial}
</Avatar>
Expand Down Expand Up @@ -109,6 +117,7 @@ export const ContactCard = ({ contact }) => {
backgroundColor: `hsla(${backgroundColor},50%,80%,50%)`,
border: '1px solid grey',
}}
src={data}
>
{initial}
</Avatar>
Expand Down

0 comments on commit c0fd832

Please sign in to comment.