this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

make reason pressable

+17 -22
+17 -22
apps/expo/src/components/feed-post.tsx
··· 1 - import { Image, Text, TouchableOpacity, View } from "react-native"; 1 + import { Image, Pressable, Text, TouchableOpacity, View } from "react-native"; 2 2 import { Link } from "expo-router"; 3 - import { AppBskyFeedPost, type AppBskyFeedDefs } from "@atproto/api"; 3 + import { AppBskyFeedDefs, AppBskyFeedPost } from "@atproto/api"; 4 4 import { Heart, MessageSquare, Repeat, User } from "lucide-react-native"; 5 5 6 6 import { useLike, useRepost } from "../lib/hooks"; ··· 40 40 )} 41 41 // onLayout={(x) => console.log(x.nativeEvent.layout)} 42 42 > 43 - {item.reason && ( 44 - <View className="mb-1 ml-16 flex-1 flex-row items-center"> 45 - {reasonToText(item.reason as AppBskyFeedDefs.ReasonRepost)} 46 - </View> 47 - )} 43 + <Reason item={item} /> 48 44 <View className="flex-1 flex-row"> 49 45 {/* left col */} 50 46 <View className="flex flex-col items-center px-2"> ··· 143 139 ); 144 140 }; 145 141 146 - const reasonToText = (reason: AppBskyFeedDefs.ReasonRepost) => { 147 - switch (reason.$type) { 148 - case "app.bsky.feed.defs#reasonRepost": 149 - return ( 150 - <> 151 - <Repeat color="#1C1C1E" size={12} /> 152 - <Text className="ml-1.5 flex-1 text-sm" numberOfLines={1}> 153 - Reposted by {reason.by.displayName ?? reason.by.handle} 154 - </Text> 155 - </> 156 - ); 157 - default: 158 - console.log("unknown reason type", reason.$type); 159 - return null; 160 - } 142 + const Reason = ({ item }: Props) => { 143 + if (!AppBskyFeedDefs.isReasonRepost(item.reason)) return null; 144 + assert(AppBskyFeedDefs.validateReasonRepost(item.reason)); 145 + 146 + return ( 147 + <Link href={`/profile/${item.reason.by.handle}`} asChild> 148 + <Pressable className="mb-1 ml-12 flex-1 flex-row items-center"> 149 + <Repeat color="#1C1C1E" size={12} /> 150 + <Text className="ml-2 flex-1 text-sm" numberOfLines={1}> 151 + Reposted by {item.reason.by.displayName ?? item.reason.by.handle} 152 + </Text> 153 + </Pressable> 154 + </Link> 155 + ); 161 156 };