Skip to content

Commit

Permalink
fix: display profile picture (#127)
Browse files Browse the repository at this point in the history
Signed-off-by: Iuri Pereira <[email protected]>
  • Loading branch information
iuricmp authored Aug 5, 2024
1 parent 531f503 commit 6b4c62b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion mobile/app/[account]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@ export default function Page() {
try {
setLoading("Loading account...");
const response = await search.getJsonUserByName(accountName);
setUser(response);

if (!response) {
setUser(undefined);
setError(`The account '${accountName}' does not exist.`);
return;
} else {
// TODO: add avatar to indexer and avoid querying on chain
const user = await userCache.getUser(response.address);
response.avatar = user.avatar;
setUser(response);
}

const { followers } = await search.GetJsonFollowers(response.address);
Expand Down
8 changes: 5 additions & 3 deletions mobile/components/view/account/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useMemo } from "react";
import { Image, StyleSheet, TouchableOpacity, View } from "react-native";
import { StyleSheet, TouchableOpacity, View } from "react-native";
import Text from "@gno/components/text";
import Layout from "@gno/components/layout";
import { colors } from "@gno/styles/colors";
import Button from "@gno/components/button";
import { Following, Post, User } from "@gno/types";
import FeedView from "../feed/feed-view";
import Avatar from "@gno/components/avatar/avatar";

interface Props {
onPressFollowing: () => void;
Expand Down Expand Up @@ -39,11 +39,13 @@ function AccountView(props: Props) {

const isFollowed = useMemo(() => followers.find((f) => f.address === currentUser.address) != null, [user, followers]);

const avarUri = user.avatar ? user.avatar : "https://www.gravatar.com/avatar/tmp";

return (
<>
<View style={styles.container}>
<View style={styles.banner}>
<Image source={{ uri: "https://www.gravatar.com/avatar/tmp" }} style={styles.avatar} />
<Avatar uri={avarUri} style={styles.avatar} />
</View>

<View style={styles.followButtonRow}>
Expand Down

0 comments on commit 6b4c62b

Please sign in to comment.