about summary refs log tree commit diff
path: root/src/view/com/util/UserInfoText.tsx
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2022-11-09 13:12:03 -0600
committerPaul Frazee <pfrazee@gmail.com>2022-11-09 13:12:03 -0600
commit41a18bf32fb4862681804150ba1a5fe2517b9d90 (patch)
tree7dd5c83ed162d138b2b09233d0bcc43bba0c9214 /src/view/com/util/UserInfoText.tsx
parent0cdfd089f542526276781264045d13f12657d431 (diff)
downloadvoidsky-41a18bf32fb4862681804150ba1a5fe2517b9d90.tar.zst
Add creator to scene profile header
Diffstat (limited to 'src/view/com/util/UserInfoText.tsx')
-rw-r--r--src/view/com/util/UserInfoText.tsx22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/view/com/util/UserInfoText.tsx b/src/view/com/util/UserInfoText.tsx
index 77fb59886..755e6ef4f 100644
--- a/src/view/com/util/UserInfoText.tsx
+++ b/src/view/com/util/UserInfoText.tsx
@@ -1,6 +1,7 @@
 import React, {useState, useEffect} from 'react'
 import * as GetProfile from '../../../third-party/api/src/client/types/app/bsky/actor/getProfile'
 import {StyleProp, Text, TextStyle} from 'react-native'
+import {Link} from './Link'
 import {useStores} from '../../../state'
 
 export function UserInfoText({
@@ -10,6 +11,7 @@ export function UserInfoText({
   failed,
   prefix,
   style,
+  asLink,
 }: {
   did: string
   attr?: keyof GetProfile.OutputSchema
@@ -17,6 +19,7 @@ export function UserInfoText({
   failed?: string
   prefix?: string
   style?: StyleProp<TextStyle>
+  asLink?: boolean
 }) {
   attr = attr || 'handle'
   loading = loading || '...'
@@ -46,9 +49,26 @@ export function UserInfoText({
     }
   }, [did, store.api.app.bsky])
 
+  if (asLink) {
+    const title = profile?.displayName || profile?.handle || 'User'
+    return (
+      <Link
+        href={`/profile/${profile?.handle ? profile.handle : did}`}
+        title={title}>
+        <Text style={style}>
+          {didFail
+            ? failed
+            : profile
+            ? `${prefix || ''}${profile[attr]}`
+            : loading}
+        </Text>
+      </Link>
+    )
+  }
+
   return (
     <Text style={style}>
-      {didFail ? failed : profile ? `${prefix}${profile[attr]}` : loading}
+      {didFail ? failed : profile ? `${prefix || ''}${profile[attr]}` : loading}
     </Text>
   )
 }