Skip to content

Commit

Permalink
Add fallback to default image and fix frontend Dockerfile (#633)
Browse files Browse the repository at this point in the history
* fix: ci

* fix: image and dockerfile

---------

Co-authored-by: orig <[email protected]>
  • Loading branch information
origranot and orig authored Dec 24, 2023
1 parent 7f0cfee commit 5dcb2ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ WORKDIR /app
ARG API_DOMAIN
ARG CLIENTSIDE_API_DOMAIN
ARG DOMAIN
ARG STORAGE_BUCKET
ARG STORAGE_DOMAIN

# Set environment variables
ENV NODE_ENV=production
Expand Down
15 changes: 11 additions & 4 deletions apps/frontend/src/components/navbar/profile/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,17 @@ export const Profile = component$(({ user }: ProfileProps) => {
});

export const getProfilePictureUrl = async (id: string, name: string) => {
const response = await fetch(`${process.env.STORAGE_DOMAIN}/${PROFILE_PICTURE_PREFIX}/${id}`);
if (response.ok) {
return `${process.env.STORAGE_DOMAIN}/${PROFILE_PICTURE_PREFIX}/${id}?lastModified=${response.headers.get('last-modified')}`;
const DEFAULT_URL = `https://ui-avatars.com/api/?name=${name}`;
let url = DEFAULT_URL;

try {
const response = await fetch(`${process.env.STORAGE_DOMAIN}/${PROFILE_PICTURE_PREFIX}/${id}`);
if (response.ok) {
url = `${process.env.STORAGE_DOMAIN}/${PROFILE_PICTURE_PREFIX}/${id}?lastModified=${response.headers.get('last-modified')}`;
}
} catch (err) {
url = DEFAULT_URL;
}

return `https://ui-avatars.com/api/?name=${name}`;
return url;
};

0 comments on commit 5dcb2ee

Please sign in to comment.