[IMPROVE] - creating an Avatar type file

This commit is contained in:
Alex Junior 2021-08-01 22:41:15 -03:00
parent 3f75741dee
commit ca2e28f893
3 changed files with 30 additions and 28 deletions

View File

@ -6,30 +6,7 @@ import { settings as RocketChatSettings } from '@rocket.chat/sdk';
import { avatarURL } from '../../utils/avatar';
import Emoji from '../markdown/Emoji';
export interface IAvatar {
server?: string;
style?: any,
text?: string;
avatar?: string;
emoji?: string;
size?: number;
borderRadius?: number;
type?: string;
children?: JSX.Element;
user?: {
id: string;
token: string;
};
theme: string;
onPress?(): void;
getCustomEmoji(): any;
avatarETag?: string;
isStatic?: boolean;
rid?: string;
blockUnauthenticatedAccess?: boolean;
serverVersion?: string;
}
import {TAvatar} from "./types";
const Avatar = React.memo(({
text,
@ -50,7 +27,7 @@ const Avatar = React.memo(({
rid,
blockUnauthenticatedAccess,
serverVersion
}: Partial<IAvatar>) => {
}: Partial<TAvatar>) => {
if ((!text && !avatar && !emoji && !rid) || !server) {
return null;
}

View File

@ -4,13 +4,15 @@ import { Q } from '@nozbe/watermelondb';
import database from '../../lib/database';
import { getUserSelector } from '../../selectors/login';
import Avatar, {IAvatar} from './Avatar';
import Avatar from './Avatar';
import {TAvatar} from "./types";
class AvatarContainer extends React.Component<Partial<IAvatar>, any> {
class AvatarContainer extends React.Component<Partial<TAvatar>, any> {
private mounted: boolean;
private subscription!: any;
constructor(props: Partial<IAvatar>) {
constructor(props: Partial<TAvatar>) {
super(props);
this.mounted = false;
this.state = { avatarETag: '' };

View File

@ -0,0 +1,23 @@
export type TAvatar = {
server: string;
style: any,
text: string;
avatar: string;
emoji: string;
size: number;
borderRadius: number;
type: string;
children: JSX.Element;
user: {
id: string;
token: string;
};
theme: string;
onPress(): void;
getCustomEmoji(): any;
avatarETag: string;
isStatic: boolean;
rid: string;
blockUnauthenticatedAccess: boolean;
serverVersion: string;
}