Skip to content

Commit

Permalink
use util
Browse files Browse the repository at this point in the history
  • Loading branch information
saulmc committed Jul 2, 2024
1 parent 424f607 commit eeab2dc
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions components/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { actionSecondaryColor, textSecondaryColor } from "@styles/colors";
import { AvatarSizes } from "@styles/sizes";
import { getFirstLetterForAvatar } from "@utils/getFirstLetterForAvatar";
import { Image } from "expo-image";
import React, { useCallback, useState } from "react";
import {
Expand All @@ -20,12 +21,6 @@ type Props = {
name?: string | undefined;
};

const getFirstLetter = (name: string) => {
return name.startsWith("0x")
? name.slice(0, 2)
: name.charAt(0).toUpperCase();
};

function Avatar({
uri,
size = AvatarSizes.default,
Expand All @@ -35,7 +30,7 @@ function Avatar({
}: Props) {
const colorScheme = useColorScheme();
const styles = getStyles(colorScheme, size);
const firstLetter = getFirstLetter(name || "");
const firstLetter = getFirstLetterForAvatar(name || "");
const [didError, setDidError] = useState(false);

const handleImageError = useCallback(() => {
Expand Down

0 comments on commit eeab2dc

Please sign in to comment.