Skip to content

Commit

Permalink
fix: rendering Admin UI with avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
cyp3rius committed Jan 13, 2025
1 parent d0cb34f commit 2547e8a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions admin/src/api/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const authorSchema = z.object({
}).nullable(),
}),
}),
z.string(),
]).nullable().optional(),
});

Expand Down
6 changes: 5 additions & 1 deletion admin/src/components/UserAvatar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Avatar } from '@strapi/design-system';
import { FC } from 'react';
import { isObject } from 'lodash';
import { Author } from '../../api/schemas';
import { renderInitials } from '../../utils';

Expand All @@ -11,7 +12,10 @@ type Props = Readonly<Pick<Author, 'avatar'> & {
}>
export const UserAvatar: FC<Props> = ({ avatar, isAdminComment, name }) => {
if (avatar) {
const image = 'formats' in avatar ? avatar.formats?.thumbnail?.url ?? avatar.url : avatar.url;
const image = isObject(avatar) ?
('formats' in avatar ? avatar.formats?.thumbnail?.url : avatar.url):
avatar;

if (isAdminComment) {
return (
<AdminAvatar>
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "strapi-plugin-comments",
"version": "3.0.2",
"version": "3.0.3",
"description": "Strapi - Comments plugin",
"strapi": {
"name": "comments",
Expand Down Expand Up @@ -34,7 +34,6 @@
"publish:beta": "npm publish --tag beta",
"build": "yarn clean && strapi-plugin build",
"clean": "rm -rf build",
"develop": "nodemon --exec \"yarn build:dev\"",
"test:unit": "jest --verbose --coverage",
"test:unit:watch": "jest --verbose --watch",
"test:unit:ci": "CI=true jest --ci --runInBand --verbose --coverage",
Expand Down

0 comments on commit 2547e8a

Please sign in to comment.