The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/contexts/AvatarUrlContext.ts

18 lines
798 B

import { createContext, useContext } from 'react';
const dummy = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQYV2Oora39DwAFaQJ3y3rKeAAAAABJRU5ErkJggg==';
type AvatarContextValue = {
getUserPathAvatar: (uid: string, etag?: string) => string;
getRoomPathAvatar: (...args: any) => string;
};
const AvatarUrlContextValueDefault: AvatarContextValue = {
getUserPathAvatar: () => dummy,
getRoomPathAvatar: () => dummy,
};
export const AvatarUrlContext = createContext<AvatarContextValue>(AvatarUrlContextValueDefault);
export const useRoomAvatarPath = (): ((uid: string, etag?: string) => string) => useContext(AvatarUrlContext).getRoomPathAvatar;
export const useUserAvatarPath = (): ((...args: any) => string) => useContext(AvatarUrlContext).getUserPathAvatar;