Skip to content

Commit

Permalink
Remove redundant CDN handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Sep 16, 2024
1 parent f8dd991 commit 817bc7e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions apps/meteor/client/providers/AvatarUrlProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AvatarUrlContext, useSetting } from '@rocket.chat/ui-contexts';
import { AvatarUrlContext } from '@rocket.chat/ui-contexts';
import type { ReactNode } from 'react';
import React, { useMemo } from 'react';

Expand All @@ -10,19 +10,15 @@ type AvatarUrlProviderProps = {
};

const AvatarUrlProvider = ({ children }: AvatarUrlProviderProps) => {
const cdnAvatarUrl = String(useSetting('CDN_PREFIX') || '');
const contextValue = useMemo(
() => ({
getUserPathAvatar: ((): ((uid: string, etag?: string) => string) => {
if (cdnAvatarUrl) {
return (uid: string, etag?: string): string => `${cdnAvatarUrl}/avatar/${uid}${etag ? `?etag=${etag}` : ''}`;
}
return (uid: string, etag?: string): string => getURL(`/avatar/${uid}${etag ? `?etag=${etag}` : ''}`);
})(),
getRoomPathAvatar: ({ type, ...room }: any): string =>
roomCoordinator.getRoomDirectives(type || room.t).getAvatarPath({ username: room._id, ...room }) || '',
}),
[cdnAvatarUrl],
[],
);

return <AvatarUrlContext.Provider children={children} value={contextValue} />;
Expand Down

0 comments on commit 817bc7e

Please sign in to comment.