about summary refs log tree commit diff
path: root/src/screens/Post/PostLikedBy.tsx
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2024-12-11 22:24:22 +0000
committerGitHub <noreply@github.com>2024-12-11 22:24:22 +0000
commit48346edde606e8cb5cd2071a1a090610ff1670a9 (patch)
tree72d10da706a1084e39b8e9e6661b4934f396ba90 /src/screens/Post/PostLikedBy.tsx
parent89c6ca94fe5f13a06d592be0771ebc27774b01ea (diff)
downloadvoidsky-48346edde606e8cb5cd2071a1a090610ff1670a9.tar.zst
More exact counts (#7059)
* post liked by

* rm unnecessary layout.center

* do post quotes/reposts

* set height of header to prevent layout shifts
Diffstat (limited to 'src/screens/Post/PostLikedBy.tsx')
-rw-r--r--src/screens/Post/PostLikedBy.tsx29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/screens/Post/PostLikedBy.tsx b/src/screens/Post/PostLikedBy.tsx
index d35d33243..683818690 100644
--- a/src/screens/Post/PostLikedBy.tsx
+++ b/src/screens/Post/PostLikedBy.tsx
@@ -1,13 +1,12 @@
 import React from 'react'
-import {msg} from '@lingui/macro'
-import {useLingui} from '@lingui/react'
+import {Plural, Trans} from '@lingui/macro'
 import {useFocusEffect} from '@react-navigation/native'
 
 import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types'
 import {makeRecordUri} from '#/lib/strings/url-helpers'
+import {usePostThreadQuery} from '#/state/queries/post-thread'
 import {useSetMinimalShellMode} from '#/state/shell'
 import {PostLikedBy as PostLikedByComponent} from '#/view/com/post-thread/PostLikedBy'
-import {ViewHeader} from '#/view/com/util/ViewHeader'
 import * as Layout from '#/components/Layout'
 
 type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostLikedBy'>
@@ -15,7 +14,12 @@ export const PostLikedByScreen = ({route}: Props) => {
   const setMinimalShellMode = useSetMinimalShellMode()
   const {name, rkey} = route.params
   const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey)
-  const {_} = useLingui()
+  const {data: post} = usePostThreadQuery(uri)
+
+  let likeCount
+  if (post?.thread.type === 'post') {
+    likeCount = post.thread.post.likeCount
+  }
 
   useFocusEffect(
     React.useCallback(() => {
@@ -25,7 +29,22 @@ export const PostLikedByScreen = ({route}: Props) => {
 
   return (
     <Layout.Screen>
-      <ViewHeader title={_(msg`Liked By`)} />
+      <Layout.Header.Outer>
+        <Layout.Header.BackButton />
+        <Layout.Header.Content>
+          {post && (
+            <>
+              <Layout.Header.TitleText>
+                <Trans>Liked By</Trans>
+              </Layout.Header.TitleText>
+              <Layout.Header.SubtitleText>
+                <Plural value={likeCount ?? 0} one="# like" other="# likes" />
+              </Layout.Header.SubtitleText>
+            </>
+          )}
+        </Layout.Header.Content>
+        <Layout.Header.Slot />
+      </Layout.Header.Outer>
       <PostLikedByComponent uri={uri} />
     </Layout.Screen>
   )