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

fix: Fix Jellyseerr Avatar Loading Issue #2197

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/server/api/routers/media-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const mediaRequestsRouter = createTRPCRouter({
name: genericItem.name,
userName: item.requestedBy.displayName,
userProfilePicture: constructAvatarUrl(appUrl, item.requestedBy.avatar),
fallbackUserProfilePicture: constructfallbackAvatarUrl(appUrl, item.requestedBy.avatar),
userLink: `${appUrl}/users/${item.requestedBy.id}`,
userRequestCount: item.requestedBy.requestCount,
airDate: genericItem.airDate,
Expand Down Expand Up @@ -119,6 +120,7 @@ export const mediaRequestsRouter = createTRPCRouter({
id: user.id,
userName: user.displayName,
userProfilePicture: constructAvatarUrl(appUrl, user.avatar),
fallbackUserProfilePicture: constructfallbackAvatarUrl(appUrl, user.avatar),
userLink: `${appUrl}/users/${user.id}`,
userRequestCount: user.requestCount,
};
Expand Down Expand Up @@ -147,6 +149,16 @@ const constructAvatarUrl = (appUrl: string, avatar: string) => {
return `${appUrl}/${avatar}`;
};

const constructfallbackAvatarUrl = (appUrl: string, avatar: string) => {
const isAbsolute = avatar.startsWith('http://') || avatar.startsWith('https://');

if (isAbsolute) {
return avatar;
}

return `${appUrl}/avatarproxy/${avatar}`;
};

const retrieveDetailsForItem = async (
baseUrl: string,
type: OverseerrResponseItem['type'],
Expand Down
16 changes: 11 additions & 5 deletions src/widgets/media-requests/MediaRequestListTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Stack,
Text,
Tooltip,
Avatar,
useMantineTheme,
} from '@mantine/core';
import { notifications } from '@mantine/notifications';
Expand Down Expand Up @@ -170,14 +171,19 @@ function MediaRequestListTile({ widget }: MediaRequestListWidgetProps) {
</Flex>
<Stack justify="center">
<Flex gap="xs">
<Image
<Avatar
src={item.userProfilePicture}
width={25}
height={25}
size={25}
alt="requester avatar"
radius="xl"
withPlaceholder
/>
>
<Image
src={item.fallbackUserProfilePicture}
alt="requester avatar"
radius="xl"
withPlaceholder
/>
</Avatar>
<Anchor
href={item.userLink}
target={widget.properties.openInNewTab ? '_blank' : '_self'}
Expand Down
5 changes: 4 additions & 1 deletion src/widgets/media-requests/MediaRequestStatsTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Stack,
Text,
Tooltip,
Image,
useMantineTheme,
} from '@mantine/core';
import { useElementSize } from '@mantine/hooks';
Expand Down Expand Up @@ -163,7 +164,9 @@ function MediaRequestStatsTile({ widget }: MediaRequestStatsWidgetProps) {
/>
</Tooltip.Floating>
)}
<Avatar radius="xl" size={45} src={user.userProfilePicture} alt="user avatar" />
<Avatar radius="xl" size={45} src={user.userProfilePicture} alt="user avatar" >
<Image src={user.fallbackUserProfilePicture} alt="user avatar" />
</Avatar>
<Stack spacing={0} style={{ flex: 1 }}>
<Text>{user.userName}</Text>
<Text size="xs">
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/media-requests/media-request-types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type MediaRequest = {
name: string;
userName: string;
userProfilePicture: string;
fallbackUserProfilePicture: string;
userLink: string;
userRequestCount: number;
airDate?: string;
Expand All @@ -22,6 +23,7 @@ export type Users = {
id: number;
userName: string;
userProfilePicture: string;
fallbackUserProfilePicture: string;
userLink: string;
userRequestCount: number;
};
Expand Down